Microsoft requires a minimum level of LDAP encryption
We have placed the Example - Active Directory Change Password JNDI Example code in our Code repository
The updateUserPassword method is shown below:
/** * Update User Password in Microsoft Active Directory * @param username * @param password */ public void updateUserPassword(String username, String password) { try { System.out.println("updating password...\n"); String quotedPassword = "\"" + password + "\""; char unicodePwd[] = quotedPassword.toCharArray(); byte pwdArray[] = new byte[unicodePwd.length * 2]; for (int i = 0; i < unicodePwd.length; i++) { pwdArray[i * 2 + 1] = (byte) (unicodePwd[i] >>> 8); pwdArray[i * 2 + 0] = (byte) (unicodePwd[i] & 0xff); } System.out.print("encoded password: "); for (int i = 0; i < pwdArray.length; i++) { System.out.print(pwdArray[i] + " "); } System.out.println(); ModificationItem[] mods = new ModificationItem[1]; mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("UnicodePwd", pwdArray)); ldapContext.modifyAttributes("cn=" + username + BASE_NAME, mods); } catch (Exception e) { System.out.println("update password error: " + e); } }