我试图通过使用UserPrincipal更改Active Directory中的用户帐户属性。使用UserPrincipal更改AD用户帐户属性
我读过,我们必须使用具有对Active Directory的写入访问权限而不是当前登录用户的特殊帐户。所以,我创建了特殊课程,通过使用特殊帐户来模仿。但我仍然有
System.UnauthorizedAccessException: General access denied error
在user.Save(CTX);线。
System.Security.Principal.WindowsImpersonationContext newUser = clsImpersonate.ImpersonateUser("ADUser", "ADPassword");
if (newUser != null)
{
PrincipalContext ctx = blAD.GetAdminPrincipalContext();
UserPrincipal user = blAD.GetUserPrincipal(this.SAMAccount);
user.Enabled = false;
user.Save(ctx);
newUser.Undo();
}
我该如何达到这个要求?谢谢。