Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

active directory & change password problem

  Asked By: Lamberta    Date: Dec 10    Category: Java    Views: 2866
  

My web application use microsoft active directory as user repository
for user managment subsystem via ldap. but I can not change password
of user with ldap API.
Is there anyone know how can I reset password of active directory user
via ldap??

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Hehet Chalthoum     Answered On: Dec 10

At the first step you sould connect to ldap  with SSL to modify password  of agents then you should unicode your password string with UTF-16LE
I put a sample for you :


String quotedPassword = '\"' + agent.getPassword() + '\"';
byte[] unicodePassword;
DirContext sctx = null;

try {
unicodePassword = quotedPassword.getBytes("UTF-16LE");
} catch (UnsupportedEncodingException uee) {
throw new LdapAccessException("Cannot encode password" + "???? ???? ???? ??? ????? ???????", uee);
}

ModificationItem[] mods = new ModificationItem[2];

mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("unicodePwd", unicodePassword));

mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("userAccountControl", Integer.toString(Agent.UF_NORMAL_ACCOUNT + Agent.UF_DONT_EXPIRE_PASSWD)));

modifySecurely(agent, mods);

 
Didn't find what you were looking for? Find more on active directory & change password problem Or get search suggestion and latest updates.




Tagged: