我在解锁 AD 上的锁定帐户时遇到了一些问题。
我会保持非常简单。我假设该帐户当前已被锁定。
UserPrincipal oUserPrincipal = ADMethods.GetUser("test.user");
oUserPrincipal.UnlockAccount();
oUserPrincipal.Save();`
oUserPrincipal 通过 PrincipalContext 使用 TEST AD 上的管理员帐户返回
现在 ..
oUserPrincipal.UnlockAccount(); 正在生成异常
System.UnauthorizedAccessException
检查“测试 AD 服务器”上的日志时,它返回一个失败的协商,说明“test.user”被锁定。由于我使用管理员帐户返回用户主体,为什么 unlockAccount 方法会产生错误?
感谢您的帮助。
例外情况如下。
System.UnauthorizedAccessException: Access is denied.
at System.DirectoryServices.Interop.UnsafeNativeMetho ds.IAds.SetInfo()
at System.DirectoryServices.DirectoryEntry.CommitChan ges()
at System.DirectoryServices.AccountManagement.SDSUtil s.WriteAttribute(String dePath, String attribute, Int32 value, NetCred credentials, AuthenticationTypes authTypes)
at System.DirectoryServices.AccountManagement.ADStore Ctx.WriteAttribute(Principal p, String attribute, Int32 value)
at System.DirectoryServices.AccountManagement.ADStore Ctx.UnlockAccount(AuthenticablePrincipal p)
at System.DirectoryServices.AccountManagement.Account Info.UnlockAccount()
at ADMethodsAccountManagement.UnlockUserAccount(Strin g sUserName) in C:\Users\christian.debono\documents\visual studio 2010\Projects\UnlockApp\UnlockApp\ADMethodsAccount Management.cs:line 182
at UnlockApp.Form1.UnlockButton_Click(Object sender, EventArgs e) in C:\Users\christian.debono\documents\visual studio 2010\Projects\UnlockApp\UnlockApp\Form1.cs:line 30
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)