I am using System.DirectoryServices.AccountManagement apis to create a new user/disable an account in Active Directory. When i am trying to create a new user, and set its password, m/c throws an exception with the message The RPC server is unavailable. (Exception from HRESULT: 0x800706BA). The following snippet is used to create and persist the user.
UserPrincipal user = new UserPrincipal(ctx);
user.GivenName = "Andrew";
user.Surname = "Green";
user.EmailAddress = "agreeen@gmail.com";
user.SamAccountName = "agreen";
user.Save();
user.SetPassword("Pqw^&12");
user.Save();
When i execute this, the code throws an exception as soon as it tries to set a password. After a little search on the net, I tried out the following things.
Since acct agreen gets created without password, there is no privilege or connection issue. I added Windows Management Instrumentation(WMI) as exception to the windows firewall on my AD machine I ensured that the following services RPC Endpoint Mapper, Remote Procedure Call, Remote Registry are running on the AD machine. Ensured that the account, that is used to connect to AD machine, has Enable remote Controlchecked I verified that port 135 is not blocked on AD machine The setup that i have is, I have box b1 running Microsoft Windows 7 Professional, which is trying to connect to a box b2, running Microsoft Windows Server 2008 R2 enterprise. The c# code is running on .Net4.5 framework on b1, and trying to create account on b2.
When i tried running the code from the same box(i.e. box with AD), I was able to successfully create the account with password, when i specified the ip address as localhost, but when i specified it as m/c ip address, it failed with the same exception
Please let me know what i am doing wrong.
Thanks
User contributions licensed under CC BY-SA 3.0