c# - How to check connection is made into a server when using PrincipalContext? -


i need change password of windows user in machine connected in same network. connecting machine using principalcontextmethod, specified user , change password.

 private bool changeuserpassword(string servername,string serverip,string adminusername, string adminuserpassword, string username, string newiispassword)     {                                                using (var context = new principalcontext(contexttype.machine, servername, adminusername, adminuserpassword))                             using (var user = userprincipal.findbyidentity(context, identitytype.samaccountname, username))             {                 user.setpassword(newiispassword);                 user.save();             } } 

the problem won't connection server when providing 'servername' works 'serverip' , vice versa. if connected context.connectedserver show server name, if not showing unknown path or bad username error.

if connection not made use serverip parameter

 using (var context = new principalcontext(contexttype.machine, serverip, adminusername, adminuserpassword))   

for tried if( context.connectedserver != servername) know connection not working , put above code inside it.but return error since there no connectedserver.

how can check connection server made or not?

your dns server may not configured on network. please use fqdn of machine name.

example of full computer name


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -