【发布时间】:2023-04-04 14:07:01
【问题描述】:
我编写了一个允许用户更改其 AD 密码的工具。该工具在我的公司域上运行没有问题,但是在使用 citrix 的客户机器上运行它时,我收到以下错误消息:
System.Reflection.TargetInvocationException:调用的目标已抛出异常。 ---> System.UnauthorizedAccessException:访问被拒绝。 (来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED)) --- 内部异常堆栈跟踪结束 --- 在 System.DirectoryServices.DirectoryEntry.Invoke(字符串方法名,对象 [] 参数) 在 System.DirectoryServices.AccountManagement.SDSUtils.ChangePassword(DirectoryEntry de,字符串 oldPassword,字符串 newPassword) 在 System.DirectoryServices.AccountManagement.ADStoreCtx.ChangePassword(AuthenticablePrincipal p,字符串 oldPassword,字符串 newPassword) 在 CitrixPWChangeBackend.ActiveDirectory.ChangePasswordForCurrentUser(String oldPw, String newPw, Boolean& errorWrongPw, Boolean& errorPasswordRules, String& errorMessage)
导致该错误的行是:
UserPrincipal.Current.ChangePassword(oldPw, newPw);
“oldPW”当然是正确的
【问题讨论】:
-
您能否使用同一用户成功运行该工具但登录到您客户的一台机器的控制台?这样做可以排除 Citrix,因为我不希望 Citrix 环境引入访问被拒绝异常。
-
同时我发现,用户将属性 UserCannotChangePassword 设置为 true。在扯掉管理员头之后,我等待获得另一个帐户来正确测试我的代码。
-
谢谢,多诺万。原因正如预期的那样在配置方面。
标签: winforms active-directory access-denied citrix change-password