接上文:
获取到ctx后执行用户的修改密码操作:
直接贴代码:
// 512
int UF_NORMAL_ACCOUNT = 0x0200;
// 65536
int UF_DONT_EXPIRE_PASSWD = 0x10000;
// 修改密码策略
ModificationItem[] mods = new ModificationItem[2];
String newQuotedPassword = “”" + req.getPassword() + “”";
byte[] newUnicodePassword = null;
try {
newUnicodePassword = newQuotedPassword.getBytes(“UTF-16LE”);
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute(“unicodePwd”, newUnicodePassword));
mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(“userAccountControl”,
Integer.toString(UF_NORMAL_ACCOUNT + UF_DONT_EXPIRE_PASSWD)));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// Perform the update
try {