Access Denied when trying to change password from c#

∥☆過路亽.° 提交于 2019-12-11 06:32:54

问题


I wrote a tool that allows users to change their AD-password. This tool works without problems on my companies domain, but when running it on our customers machine with citrix I receive the following error message:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) --- End of inner exception stack trace --- at 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)

The Line causing that Error is:

UserPrincipal.Current.ChangePassword(oldPw, newPw);

"oldPW" is correct, of course


回答1:


The "magic" reason was a policy for that user causing the property "UserCannotChangePassword" to be true. No Citrix specific issue.



来源:https://stackoverflow.com/questions/15971736/access-denied-when-trying-to-change-password-from-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!