UserPrincipal を使用して Active Directory のユーザー アカウント プロパティを変更しようとしています。
現在のログオン ユーザーではなく、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();
}
どうすればこの要件を達成できますか? ありがとう。