尝试从c#更改密码时拒绝访问

时间:2013-04-12 12:43:14

标签: winforms active-directory access-denied citrix change-password

我写了一个允许用户更改其AD密码的工具。此工具在我的公司域上运行没有问题,但在使用Citrix的客户计算机上运行时,我收到以下错误消息:

  

System.Reflection.TargetInvocationException:调用目标抛出了异常。 ---> System.UnauthorizedAccessException:拒绝访问。 (HRESULT异常:0x80070005(E_ACCESSDENIED))     ---内部异常堆栈跟踪结束---     在System.DirectoryServices.DirectoryEntry.Invoke(String methodName,Object [] args)     at System.DirectoryServices.AccountManagement.SDSUtils.ChangePassword(DirectoryEntry de,String oldPassword,String newPassword)     at System.DirectoryServices.AccountManagement.ADStoreCtx.ChangePassword(AuthenticablePrincipal p,String oldPassword,String newPassword)     at CitrixPWChangeBackend.ActiveDirectory.ChangePasswordForCurrentUser(String oldPw,String newPw,Boolean& errorWrongPw,Boolean& errorPasswordRules,String& errorMessage)

导致该错误的行是:

UserPrincipal.Current.ChangePassword(oldPw, newPw);

“oldPW”是正确的,当然

1 个答案:

答案 0 :(得分:3)

“神奇”原因是该用户的策略导致属性“UserCannotChangePassword”为true。 没有Citrix特定问题。