設置的密碼在服務器中失敗。當調用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 –