The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) - C# ChangePassword


I need to change the password of a domain user on windows server 2012 r2 automatically.
For this reason I created an application which basically performs the following operations:

var userPrincipal = PrincipalContextService.AcquireUserPricipal(principalContext, model.Username);
// Validate user credentials
if (principalContext.ValidateCredentials(model.Username, model.CurrentPassword) == false)
  LoggerService.printLogError(_logger, null, "user : " + model.Username + " error ValidateCredentials", Settings);
  throw new Exception(Settings.ClientSettings.Alerts.ErrorInvalidCredentials);
userPrincipal.ChangePassword(model.CurrentPassword, model.NewPassword);

the system is able to connect to the domain controller (the controller is on another machine), it also manages to check with the old password, but when it tries to set the new password it goes into error:

System.DirectoryServices.AccountManagement.PrincipalOperationException: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) ---> System.Runtime.InteropServices.COMException: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

The two machines are protected by a firewall but I read that by opening ports 389 445 the system system should work.

Port 389 corresponds to the LDAP service while I don't know the function of port 445.

Can you tell me the port 445 what is it for?
Can you give me some other operations that I can do on the two machines for the change password operation to work?

asked on Stack Overflow Jun 17, 2020 by luca.barone • edited Jun 17, 2020 by luca.barone

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0