org.lsc.utils.directory
Class AD

java.lang.Object
  extended by org.lsc.utils.directory.AD

public class AD
extends Object

Utility class to manage specific entries for a Microsoft ActiveDirectory

Author:
Rémy-Christophe Schermesser

Field Summary
static Integer UAC_ACCOUNTDISABLE
           
static Integer UAC_DONT_EXPIRE_PASSWORD
           
static Integer UAC_DONT_REQ_PREAUTH
           
static Integer UAC_ENCRYPTED_TEXT_PWD_ALLOWED
           
static Integer UAC_HOMEDIR_REQUIRED
           
static Integer UAC_INTERDOMAIN_TRUST_ACCOUNT
           
static Integer UAC_LOCKOUT
           
static Integer UAC_MNS_LOGON_ACCOUNT
           
static Integer UAC_NORMAL_ACCOUNT
           
static Integer UAC_NOT_DELEGATED
           
static Integer UAC_PASSWD_CANT_CHANGE
           
static Integer UAC_PASSWD_NOTREQD
           
static Integer UAC_PASSWORD_EXPIRED
           
static Integer UAC_SCRIPT
          Internal values in the AD in Hex See : http://support.microsoft.com/kb/305144
static Integer UAC_SERVER_TRUST_ACCOUNT
           
static Integer UAC_SET_ACCOUNTDISABLE
           
static Integer UAC_SET_DONT_EXPIRE_PASSWORD
           
static Integer UAC_SET_DONT_REQ_PREAUTH
           
static Integer UAC_SET_ENCRYPTED_TEXT_PWD_ALLOWED
           
static Integer UAC_SET_HOMEDIR_REQUIRED
           
static Integer UAC_SET_INTERDOMAIN_TRUST_ACCOUNT
           
static Integer UAC_SET_LOCKOUT
           
static Integer UAC_SET_MNS_LOGON_ACCOUNT
           
static Integer UAC_SET_NORMAL_ACCOUNT
           
static Integer UAC_SET_NOT_DELEGATED
           
static Integer UAC_SET_PASSWD_CANT_CHANGE
           
static Integer UAC_SET_PASSWD_NOTREQD
           
static Integer UAC_SET_PASSWORD_EXPIRED
           
static Integer UAC_SET_SCRIPT
          The constants available in the configuration If it is starting by SET, it is to force the value on in the AD If it is starting by UNSET, it is to force the removing of the value in the AD
static Integer UAC_SET_SERVER_TRUST_ACCOUNT
           
static Integer UAC_SET_SMARTCARD_REQUIRED
           
static Integer UAC_SET_TEMP_DUPLICATE_ACCOUNT
           
static Integer UAC_SET_TRUSTED_FOR_DELEGATION
           
static Integer UAC_SET_TRUSTED_TO_AUTH_FOR_DELEGATION
           
static Integer UAC_SET_USE_DES_KEY_ONLY
           
static Integer UAC_SET_WORKSTATION_TRUST_ACCOUNT
           
static Integer UAC_SMARTCARD_REQUIRED
           
static Integer UAC_TEMP_DUPLICATE_ACCOUNT
           
static Integer UAC_TRUSTED_FOR_DELEGATION
           
static Integer UAC_TRUSTED_TO_AUTH_FOR_DELEGATION
           
static Integer UAC_UNSET_ACCOUNTDISABLE
           
static Integer UAC_UNSET_DONT_EXPIRE_PASSWORD
           
static Integer UAC_UNSET_DONT_REQ_PREAUTH
           
static Integer UAC_UNSET_ENCRYPTED_TEXT_PWD_ALLOWED
           
static Integer UAC_UNSET_HOMEDIR_REQUIRED
           
static Integer UAC_UNSET_INTERDOMAIN_TRUST_ACCOUNT
           
static Integer UAC_UNSET_LOCKOUT
           
static Integer UAC_UNSET_MNS_LOGON_ACCOUNT
           
static Integer UAC_UNSET_NORMAL_ACCOUNT
           
static Integer UAC_UNSET_NOT_DELEGATED
           
static Integer UAC_UNSET_PASSWD_CANT_CHANGE
           
static Integer UAC_UNSET_PASSWD_NOTREQD
           
static Integer UAC_UNSET_PASSWORD_EXPIRED
           
static Integer UAC_UNSET_SCRIPT
           
static Integer UAC_UNSET_SERVER_TRUST_ACCOUNT
           
static Integer UAC_UNSET_SMARTCARD_REQUIRED
           
static Integer UAC_UNSET_TEMP_DUPLICATE_ACCOUNT
           
static Integer UAC_UNSET_TRUSTED_FOR_DELEGATION
           
static Integer UAC_UNSET_TRUSTED_TO_AUTH_FOR_DELEGATION
           
static Integer UAC_UNSET_USE_DES_KEY_ONLY
           
static Integer UAC_UNSET_WORKSTATION_TRUST_ACCOUNT
           
static Integer UAC_USE_DES_KEY_ONLY
           
static Integer UAC_WORKSTATION_TRUST_ACCOUNT
           
 
Constructor Summary
AD()
           
 
Method Summary
static long getAccountExpires(String expireDate)
          Returns the accountexpires time in Microsoft format
static long getAccountExpires(String expireDate, String format)
          Return the accountexpires time in Microsoft format
static int getNumberOfWeeksSinceLastLogon(String lastLogonTimestamp)
          Return the number of weeks since the last logon
static String getUnicodePwd(String password)
          Encode a password so that it can be updated in Active Directory in the field unicodePwd.
static boolean userAccountControlCheck(int value, String constToCheck)
          Check if a bit is set in UserAccountControl
static int userAccountControlSet(int origValue, String[] constToApply)
          Set or unset some bits to a UserAccountControl attribute of an AD
static int userAccountControlToggle(int value, String constToApply)
          Toggle a bit in UserAccountControl
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UAC_SCRIPT

public static final Integer UAC_SCRIPT
Internal values in the AD in Hex See : http://support.microsoft.com/kb/305144


UAC_ACCOUNTDISABLE

public static final Integer UAC_ACCOUNTDISABLE

UAC_HOMEDIR_REQUIRED

public static final Integer UAC_HOMEDIR_REQUIRED

UAC_LOCKOUT

public static final Integer UAC_LOCKOUT

UAC_PASSWD_NOTREQD

public static final Integer UAC_PASSWD_NOTREQD

UAC_PASSWD_CANT_CHANGE

public static final Integer UAC_PASSWD_CANT_CHANGE

UAC_ENCRYPTED_TEXT_PWD_ALLOWED

public static final Integer UAC_ENCRYPTED_TEXT_PWD_ALLOWED

UAC_TEMP_DUPLICATE_ACCOUNT

public static final Integer UAC_TEMP_DUPLICATE_ACCOUNT

UAC_NORMAL_ACCOUNT

public static final Integer UAC_NORMAL_ACCOUNT

UAC_INTERDOMAIN_TRUST_ACCOUNT

public static final Integer UAC_INTERDOMAIN_TRUST_ACCOUNT

UAC_WORKSTATION_TRUST_ACCOUNT

public static final Integer UAC_WORKSTATION_TRUST_ACCOUNT

UAC_SERVER_TRUST_ACCOUNT

public static final Integer UAC_SERVER_TRUST_ACCOUNT

UAC_DONT_EXPIRE_PASSWORD

public static final Integer UAC_DONT_EXPIRE_PASSWORD

UAC_MNS_LOGON_ACCOUNT

public static final Integer UAC_MNS_LOGON_ACCOUNT

UAC_SMARTCARD_REQUIRED

public static final Integer UAC_SMARTCARD_REQUIRED

UAC_TRUSTED_FOR_DELEGATION

public static final Integer UAC_TRUSTED_FOR_DELEGATION

UAC_NOT_DELEGATED

public static final Integer UAC_NOT_DELEGATED

UAC_USE_DES_KEY_ONLY

public static final Integer UAC_USE_DES_KEY_ONLY

UAC_DONT_REQ_PREAUTH

public static final Integer UAC_DONT_REQ_PREAUTH

UAC_PASSWORD_EXPIRED

public static final Integer UAC_PASSWORD_EXPIRED

UAC_TRUSTED_TO_AUTH_FOR_DELEGATION

public static final Integer UAC_TRUSTED_TO_AUTH_FOR_DELEGATION

UAC_SET_SCRIPT

public static final Integer UAC_SET_SCRIPT
The constants available in the configuration If it is starting by SET, it is to force the value on in the AD If it is starting by UNSET, it is to force the removing of the value in the AD


UAC_UNSET_SCRIPT

public static final Integer UAC_UNSET_SCRIPT

UAC_SET_ACCOUNTDISABLE

public static final Integer UAC_SET_ACCOUNTDISABLE

UAC_UNSET_ACCOUNTDISABLE

public static final Integer UAC_UNSET_ACCOUNTDISABLE

UAC_SET_HOMEDIR_REQUIRED

public static final Integer UAC_SET_HOMEDIR_REQUIRED

UAC_UNSET_HOMEDIR_REQUIRED

public static final Integer UAC_UNSET_HOMEDIR_REQUIRED

UAC_SET_LOCKOUT

public static final Integer UAC_SET_LOCKOUT

UAC_UNSET_LOCKOUT

public static final Integer UAC_UNSET_LOCKOUT

UAC_SET_PASSWD_NOTREQD

public static final Integer UAC_SET_PASSWD_NOTREQD

UAC_UNSET_PASSWD_NOTREQD

public static final Integer UAC_UNSET_PASSWD_NOTREQD

UAC_SET_PASSWD_CANT_CHANGE

public static final Integer UAC_SET_PASSWD_CANT_CHANGE

UAC_UNSET_PASSWD_CANT_CHANGE

public static final Integer UAC_UNSET_PASSWD_CANT_CHANGE

UAC_SET_ENCRYPTED_TEXT_PWD_ALLOWED

public static final Integer UAC_SET_ENCRYPTED_TEXT_PWD_ALLOWED

UAC_UNSET_ENCRYPTED_TEXT_PWD_ALLOWED

public static final Integer UAC_UNSET_ENCRYPTED_TEXT_PWD_ALLOWED

UAC_SET_TEMP_DUPLICATE_ACCOUNT

public static final Integer UAC_SET_TEMP_DUPLICATE_ACCOUNT

UAC_UNSET_TEMP_DUPLICATE_ACCOUNT

public static final Integer UAC_UNSET_TEMP_DUPLICATE_ACCOUNT

UAC_SET_NORMAL_ACCOUNT

public static final Integer UAC_SET_NORMAL_ACCOUNT

UAC_UNSET_NORMAL_ACCOUNT

public static final Integer UAC_UNSET_NORMAL_ACCOUNT

UAC_SET_INTERDOMAIN_TRUST_ACCOUNT

public static final Integer UAC_SET_INTERDOMAIN_TRUST_ACCOUNT

UAC_UNSET_INTERDOMAIN_TRUST_ACCOUNT

public static final Integer UAC_UNSET_INTERDOMAIN_TRUST_ACCOUNT

UAC_SET_WORKSTATION_TRUST_ACCOUNT

public static final Integer UAC_SET_WORKSTATION_TRUST_ACCOUNT

UAC_UNSET_WORKSTATION_TRUST_ACCOUNT

public static final Integer UAC_UNSET_WORKSTATION_TRUST_ACCOUNT

UAC_SET_SERVER_TRUST_ACCOUNT

public static final Integer UAC_SET_SERVER_TRUST_ACCOUNT

UAC_UNSET_SERVER_TRUST_ACCOUNT

public static final Integer UAC_UNSET_SERVER_TRUST_ACCOUNT

UAC_SET_DONT_EXPIRE_PASSWORD

public static final Integer UAC_SET_DONT_EXPIRE_PASSWORD

UAC_UNSET_DONT_EXPIRE_PASSWORD

public static final Integer UAC_UNSET_DONT_EXPIRE_PASSWORD

UAC_SET_MNS_LOGON_ACCOUNT

public static final Integer UAC_SET_MNS_LOGON_ACCOUNT

UAC_UNSET_MNS_LOGON_ACCOUNT

public static final Integer UAC_UNSET_MNS_LOGON_ACCOUNT

UAC_SET_SMARTCARD_REQUIRED

public static final Integer UAC_SET_SMARTCARD_REQUIRED

UAC_UNSET_SMARTCARD_REQUIRED

public static final Integer UAC_UNSET_SMARTCARD_REQUIRED

UAC_SET_TRUSTED_FOR_DELEGATION

public static final Integer UAC_SET_TRUSTED_FOR_DELEGATION

UAC_UNSET_TRUSTED_FOR_DELEGATION

public static final Integer UAC_UNSET_TRUSTED_FOR_DELEGATION

UAC_SET_NOT_DELEGATED

public static final Integer UAC_SET_NOT_DELEGATED

UAC_UNSET_NOT_DELEGATED

public static final Integer UAC_UNSET_NOT_DELEGATED

UAC_SET_USE_DES_KEY_ONLY

public static final Integer UAC_SET_USE_DES_KEY_ONLY

UAC_UNSET_USE_DES_KEY_ONLY

public static final Integer UAC_UNSET_USE_DES_KEY_ONLY

UAC_SET_DONT_REQ_PREAUTH

public static final Integer UAC_SET_DONT_REQ_PREAUTH

UAC_UNSET_DONT_REQ_PREAUTH

public static final Integer UAC_UNSET_DONT_REQ_PREAUTH

UAC_SET_PASSWORD_EXPIRED

public static final Integer UAC_SET_PASSWORD_EXPIRED

UAC_UNSET_PASSWORD_EXPIRED

public static final Integer UAC_UNSET_PASSWORD_EXPIRED

UAC_SET_TRUSTED_TO_AUTH_FOR_DELEGATION

public static final Integer UAC_SET_TRUSTED_TO_AUTH_FOR_DELEGATION

UAC_UNSET_TRUSTED_TO_AUTH_FOR_DELEGATION

public static final Integer UAC_UNSET_TRUSTED_TO_AUTH_FOR_DELEGATION
Constructor Detail

AD

public AD()
Method Detail

userAccountControlSet

public static int userAccountControlSet(int origValue,
                                        String[] constToApply)
Set or unset some bits to a UserAccountControl attribute of an AD

Parameters:
origValue - the original value of UserAccessControl
constToApply - an Array of constants to apply
Returns:
the modified value

userAccountControlCheck

public static boolean userAccountControlCheck(int value,
                                              String constToCheck)
Check if a bit is set in UserAccountControl

Parameters:
value - the value of UserAccountControl
constToCheck - a constant to test
Returns:
is the attribute present

userAccountControlToggle

public static int userAccountControlToggle(int value,
                                           String constToApply)
Toggle a bit in UserAccountControl

Parameters:
value - the value of UserAccountControl
constToApply - the bit to toggle
Returns:
the modified value

getUnicodePwd

public static String getUnicodePwd(String password)
                            throws UnsupportedEncodingException
Encode a password so that it can be updated in Active Directory in the field unicodePwd.

Parameters:
password - The cleartext password to be encoded
Returns:
The value to write in AD's unicodePwd attribute
Throws:
UnsupportedEncodingException

getNumberOfWeeksSinceLastLogon

public static int getNumberOfWeeksSinceLastLogon(String lastLogonTimestamp)
Return the number of weeks since the last logon

Parameters:
lastLogonTimestamp -
Returns:
the number of weeks since the last logon

getAccountExpires

public static long getAccountExpires(String expireDate,
                                     String format)
                              throws ParseException
Return the accountexpires time in Microsoft format

Parameters:
expireDate - the date in any format
format - The format of the date expireDate. See http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html.
Returns:
the date in Microsoft AD format
Throws:
ParseException

getAccountExpires

public static long getAccountExpires(String expireDate)
                              throws ParseException
Returns the accountexpires time in Microsoft format

Parameters:
expireDate - the date in the format yyyy-MM-dd.
Returns:
the date in Microsoft AD format
Throws:
ParseException


Copyright © 2005-2010 LSC project. All Rights Reserved.