sasikals26
sasikals26

Reputation: 865

unlock user account using UNBoundID SDK

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,

enter image description here

Thanks in advance,

Upvotes: 0

Views: 917

Answers (2)

Benny
Benny

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

Tim
Tim

Reputation: 1695

You should modify the userAccountControl attribute instead. The trick is to know what value to set it to.

  • 512 Enabled Account
  • 514 Disabled Account
  • 544 Enabled, Password Not Required
  • 546 Disabled, Password Not Required
  • 66048 Enabled, Password Doesn't Expire
  • 66050 Disabled, Password Doesn't Expire
  • 66080 Enabled, Password Doesn't Expire & Not Required
  • 66082 Disabled, Password Doesn't Expire & Not Required

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

Related Questions