我正在尝试使用UNBoundID解锁AD帐户,但我无法成功。有谁可以帮我这个。?
我的一个尝试如下,
byte[] quotedPasswordBytes=null;
final String quotedPassword = '"' + flag + '"';
try {
quotedPasswordBytes = quotedPassword.getBytes("UTF-16LE");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Modification mod=new Modification(ModificationType.REPLACE, "msDS-User-Account-Control-Computed",quotedPasswordBytes);
ModifyRequest modifyRequest= new ModifyRequest(userDn, mod);
/*ModifyRequest mr = new ModifyRequest(userDn,
[new Modification(ModificationType.REPLACE, "msDS-UserAccountDisabled", "TRUE".bytes)]);*/
connection.modify(modifyRequest);
FYI,
提前致谢,
答案 0 :(得分:1)
您应该修改userAccountControl属性。诀窍是知道将它设置为什么值。
参考http://www.netvision.com/ad_useraccountcontrol.php或http://rajnishbhatia19.blogspot.com.au/2008/11/active-directory-useraccountcontrol.html或谷歌搜索代码。
try {
Modification mod = new Modification(ModificationType.REPLACE,"userAccountControl","512");
ModifyRequest mr = new ModifyRequest(userdn,mod);
LDAPResult lr = ldapcon.modify(mr);
ResultCode rc = lr.getResultCode();
if (!rc.equals(ResultCode.SUCCESS)) {
System.out.println("Something went wrong enabling the account for "+userdn);
}
} catch (LDAPException ex) {
System.out.println(ex.getMessage());
}
答案 1 :(得分:0)