调用 SetPassword 时,我收到错误:“调用目标已引发异常
本文关键字:调用 目标 异常 错误 SetPassword | 更新日期: 2023-09-27 18:37:01
服务器中设置的密码失败。
Exception.message:
Exception has been thrown by the target of an invocation
at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
那么为什么此调用将在本地(开发人员)计算机上工作,但不能在服务器上工作?
` DirectoryEntry entry = new DirectoryEntry(..);
entry.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(&(sAMAccountName=" + userName_ + "))";
DirectoryEntry userEntry = search.FindAll()[0].GetDirectoryEntry();
userEntry.Invoke("SetPassword", new object[] {password@12345#"
userEntry.CommitChanges();`
编辑:InnerException是{"RPC服务器不可用。(HRESULT 的例外:0x800706BA)"}
应用是否在两个环境中使用相同的帐户运行? 如果没有,那么根据您的问题,这可能是权限问题