posts - 598 , comments - 849 , trackbacks - 247

My Links

News

qrcode

Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.

 Subscribe

Tag Cloud

Article Categories

Archives

Post Categories

Blogs

Miscellanous

Noteworthy Stuff

Popular Posts

How to change your active directory password

Last year I posted the rules about how to remotely change your LDAP password. Its not very obvious because of the fact that the procedure depends on what server you're using (Active Directory, OpenLDAP, Novell, etc), and even then how your server is configured.

Here is how you would change your password using the LDAPS component of IP*Works!! SSL (note, an SSL connection is required in order to change your password remotely if you are an Active Directory user. Otherwise you can do this with the LDAP component in the regular IPWorks toolkit).

If you're not using IPWorks, the same rules apply, so adjust your code accordingly.  Here's a way to do it in PowerShell.

 

public void ChangePassword(string dn, string newpassword)
{
//Changing passwords depends on what directory server you're using:
//for Active Directory:

//*** You must have SSL connection in order for this to be allowed by AD!
//Also, this particular method of changing the password requires that you are already bound as Admin.
//Otherwise, you need to first delete the password providing the current value, and then

//re-add the password again with the new value.

ldap1.DN = dn;
ldap1.AttrCount = 1;
ldap1.AttrType[0] = "unicodePwd";
ldap1.AttrValueB[0] = System.Text.Encoding.Unicode.GetBytes("\"" + newpassword + "\"");
ldap1.AttrModOp[0] = LdapsAttrModOps.amoReplace;
ldap1.Modify();
if (ldap1.ResultCode != 0) { /* report/handle error here */ }

//for non-AD (ie Novell, OpenLdap, SunOne (iPlanet), etc): //No SSL is required /*
ldap1.DN = dn;
ldap1.AttrCount = 1;
ldap1.AttrType[0] = "userPassword";
ldap1.AttrValue[0] = newpassword;
ldap1.AttrModOp[0] = LdapsAttrModOps.amoReplace;
ldap1.Modify();
if (ldap1.ResultCode != 0) { /* report/handle error here */
}
*/
}

Technorati : , , , , , ,

Print | posted on Tuesday, November 28, 2006 3:19 PM | Filed Under [ Programming ]

Feedback

Gravatar

# re: How to change your active directory password

oh, that's fantastic, I have been looking for this.. cheers for sharing..

4/28/2010 12:45 AM | Linn
Gravatar

# re: How to change your active directory password

Thanks for posting a nice article
9/15/2011 6:23 AM | Ganesan K
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: