设置的密码在服务器中失败。当调用SetPassword时,我收到错误:“异常已被调用的目标抛出。”
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[] {[email protected]#"
userEntry.CommitChanges();`
编辑:的InnerException是{ “RPC服务器不可用(从HRESULT异常:0x800706BA)。”}
什么是InnerException? – SLaks
如果没有内部异常,TargetInvocationExceptions通常很没用。这可能与您的调用有关,因为它是TargetInvocationException。 –
http://blogs.msdn.com/b/alejacma/archive/2008/04/29/changepassword-method-may-fail-with-targetinvocationexception-net.aspx –