1

the set password is failed in the server.

Exception.message: Exception has been thrown by the target of an invocation at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)

Why then will this call work from a local (developer) machine, but not work from a server?

     `      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();`

EDIT : InnerException is {"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"}

Emre Yardımcı
  • 324
  • 1
  • 5
  • 11
  • 1
    What's the InnerException? – SLaks Oct 27 '13 at 23:56
  • TargetInvocationExceptions are usually pretty useless without the inner exception. It's probably got something to do with your invoke though since it's a TargetInvocationException. – Millie Smith Oct 28 '13 at 00:33
  • http://blogs.msdn.com/b/alejacma/archive/2008/04/29/changepassword-method-may-fail-with-targetinvocationexception-net.aspx – Millie Smith Oct 28 '13 at 03:38

1 Answers1

0

Does the app run under the same account in both environments? If not, then per your question, it may be a permissions issue

Stinky Towel
  • 768
  • 6
  • 26
  • what kind of permission issue ? if there is a permission problem, how it is working in local machine ? – Emre Yardımcı Oct 28 '13 at 00:32
  • @EmreYardımcı only if the program is running as an administrator can it call `SetPassword`, if you do `Run As Administrator` to start the program up dose it work then? I would put in [the program's manifest](http://stackoverflow.com/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7) file `` so it does that request for you. – Scott Chamberlain Oct 28 '13 at 00:37
  • @Emre - are the accounts that run the app locally and on the server, different? If yes, then you'll need to determine what rights your local account has that the server account doesn't - perhaps domain rights, etc. Also note the link Millie Smith posted to help you view the inner exception. This may give you more detail on the problem – Stinky Towel Oct 29 '13 at 16:58
  • inner exception is {"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"} – Emre Yardımcı Nov 21 '13 at 14:54
  • @Emre - hmmm...is the `Remote Procedure Call (RPC) service` running? Is there a firewall between these machines? – Stinky Towel Nov 21 '13 at 17:49
  • probably there is a firewall between my computer and server. my website run on the server so this server has a firewall but i already turn off firewall – Emre Yardımcı Nov 21 '13 at 18:51
  • how can i check Remote Procedure Call (RPC) service is running – Emre Yardımcı Nov 21 '13 at 18:52