Search code examples
javaactive-directoryjndi

Enabling an Active Directory account using JNDI


I have successfully created a disabled user in Active Directory via JNDI, but I am not sure how to enable it. Am I supposed to manipulate the userAccountControl attribute directly? Thanks.


Solution

  • You are right.

    Here are some values and the explanation how to use them :

    UF_TEMP_DUPLICATE_ACCOUNT       0x0100
    UF_NORMAL_ACCOUNT               0x0200
    UF_INTERDOMAIN_TRUST_ACCOUNT     0x0800
    UF_WORKSTATION_TRUST_ACCOUNT     0x1000
    UF_SERVER_TRUST_ACCOUNT       0x2000
    UF_DONT_EXPIRE_PASSWD           0x10000
    UF_SCRIPT                       0x0001
    UF_ACCOUNTDISABLE               0x0002
    UF_HOMEDIR_REQUIRED           0x0008
    UF_LOCKOUT                     0x0010
    UF_PASSWD_NOTREQD               0x0020
    UF_PASSWD_CANT_CHANGE           0x0040
    

    Exhaustive list of values here.

    For example

    userAccountControl = 544
    

    544 = 0x220 = UF_NORMAL_ACCOUNT | UF_PASSWD_NOTREQD