當我將我的應用程序發佈到我的Web服務器時。在IIS管理器中,我爲應用程序池提供了我使用的標識爲Network Service
。網絡服務應用程序池身份被拒絕訪問從AD中的組中刪除用戶
在我的應用程序中,我提供了從特定Active Directory組中刪除/添加用戶的功能。這裏是代碼:
public static void RemoveUserFromGroup(string userId, string groupName)
{
try
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "myDomain"))
{
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, groupName);
group.Members.Remove(pc, IdentityType.UserPrincipalName, userId);
group.Save();
}
}
catch (Exception E)
{
throw E;
}
}
這工作時,我測試本地,因爲我的帳戶具有處理AD時的管理員權限。所以只是爲了檢查,在頁面加載,我做這個登錄Windows用戶名:
var thread = '@System.Security.Principal.WindowsIdentity.GetCurrent().Name';
console.log(thread);
這導致NT AUTHORITYNETWORK SERVICE
。但是,當我嘗試從AD組中刪除用戶。我得到:
訪問被拒絕
如何給Network Service
訪問做到這一點?或者有另一種方法可以做到這一點?
爲什麼你刪除你的其他問題只是爲了欺騙它? https://stackoverflow.com/questions/45355257/removing-user-from-ad-not-working-when-app-is-published – Amy
@Amy,因爲我發現了更多的信息,可以提供一個更清晰的問題而不是有人不得不翻閱你和我的評論來獲取更多信息。 –
未來**編輯問題**。 – Amy