Reputation: 865
I am trying to unlock the AD account using UNBoundID, but i am unable to succeed on it. can anyone please help me on this.?
One of my try as below,
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,
Thanks in advance,
Upvotes: 0
Views: 917
Reputation: 755
it's been a while since this was asked, but the attribute to change is lockoutTime, which should be 0 to unlock
Upvotes: 0
Reputation: 1695
You should modify the userAccountControl attribute instead. The trick is to know what value to set it to.
Reference http://www.netvision.com/ad_useraccountcontrol.php or http://rajnishbhatia19.blogspot.com.au/2008/11/active-directory-useraccountcontrol.html or google for codes.
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());
}
Upvotes: 1