Changing password using DirectoryEntry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnathp
    New Member
    • Aug 2007
    • 1

    #1

    Changing password using DirectoryEntry

    hi there,
    I am trying to reset a password using this code snippet and it worked fine but only one concern I have is that, I need to let the user know if he has used a old password wrong. if the user sends a wrong password for resetting I would like to send an exception with error message stating that the old password is not correct. May be some way to allow the user to login to the box with this old password. (is that the correct way). I also need to find whether the machine is up and running. Any help would be greatly helpful to me.
    Thanks
    John
    DirectoryEntry userEntry = new DirectoryEntry( "WinNT://" + machinePath + "/Administrator", adminUserName, oldPassword, AuthenticationT ypes.Secure);
    object[] password = new object[] { oldPassword, newPassword };
    object ret = userEntry.Invok e("ChangePasswo rd", password);
    userEntry.Commi tChanges();
    userEntry.Dispo se();
Working...