Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Lamberta Schmidt   on Dec 10 In Java Category.

  
Question Answered By: Hehet Chalthoum    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);

Share: 

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


Tagged: