Changing Password in Active Directory
Hi Guys,
I am Stuck and need your immediate help : Its very urgent :
I am trying to change user password in Active Directory and getting following exception. But I am able to get all the users information from the Active Directory....
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 00002077: SvcErr: DSID-03190DC9, problem 5003 (WILL_NOT_PERFORM), data 0
My Code for changing password is as below :
public class ChangePassword
{
public static void main (String[] args)
{
Hashtable env = new Hashtable();
String userName = "CN=Bruce Lombardi,CN=Users,DC=Sphere,DC=Local";
String oldPassword = "password";
String newPassword = "password2";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
String ldapURL = "ldap://sphere3:389";
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,userName);
env.put(Context.SECURITY_CREDENTIALS,"password");
env.put(Context.PROVIDER_URL,ldapURL);
try {
DirContext ctx = new InitialDirContext(env);
//change password is a single ldap modify operation
//that deletes the old password and adds the new password
ModificationItem[] mods = new ModificationItem[1];
String oldQuotedPassword = "\"" + oldPassword + "\"";
byte[] oldUnicodePassword = oldQuotedPassword.getBytes("UTF-16LE");
String newQuotedPassword = "\"" + newPassword + "\"";
byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");
String newValue = Integer.toString(-1);
mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new
BasicAttribute("unicodePwd", oldUnicodePassword));
mods[1] = new ModificationItem(DirContext.ADD_ATTRIBUTE, new
BasicAttribute("unicodePwd", newUnicodePassword));
// Perform the update
ctx.modifyAttributes(userName, mods);
System.out.println("Changed Password SUCCESSFULLY for: " + userName);
ctx.close();
}
catch (NamingException e) {
System.err.println("Password COULD NOT be CHANGED: " + e);
}
catch (UnsupportedEncodingException e) {
System.err.println("Problem encoding password: " + e);
}
}
In my Active Directory for this user I have password never expire checked. Can I change password without using ssl connection?
Thanks

