Click here to Skip to main content
15,919,331 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i tried to change my local user account password i am getting com exception.

"Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.."

C#
DirectoryEntry user = new DirectoryEntry(adsPath, machineAndUser,txtOldPassword.Text.Trim(), AuthenticationTypes.Secure);                    //Change Password

user.InvokeSet("SetPassword", new Object[] { txtConfirmPassword.Text });
user.CommitChanges();


catch (System.Runtime.InteropServices.COMException COMex)
{
   if (COMex.ErrorCode == -2147023570 || COMex.ErrorCode == -2147024810      ||COMex.ErrorCode == -2147023677)
{
  MessageBox.Show("Unable to change password due to unknown user name or bad       password\nErr Msg: " + COMex.Message, "CreateUser");
}
}
Posted
Updated 17-Oct-12 23:00pm
v3

1 solution

Calling 'SetPassword' needs two things: Kerberos and the correct permissions. You must be an adminstrator to call 'SetPassword' - which makes sense if you think about it. If you are passing the user's credentials to the DirectoryEntry and binding with them, you will be binding with the user's permissions and I doubt Adminstrator is one of them. This would also be why 'ChangePassword' works, because this call is intended for user's to change their own password. 'SetPassword' is much more powerful as it can override any password policy settings you have in place. Include your code for the DirectoryEntry and I might be able to point out any other issues. Also make sure you include your exact connection string to your LDAP source in your post (it makes a difference).
 
Share this answer
 
Comments
SoMad 7-Apr-13 6:17am    
Taken from here: http://forums.asp.net/t/108959.aspx/1[^]

Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900