public class LDAPUtil
extends java.lang.Object
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
LDAPUtil.SRVRecord
SRV record entry 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
OBJECT_CLASS_ATTR
"objectClass" 
 | 
static java.lang.String | 
OBJECT_GUID_ATTR
The Active Directory unique identifier for an object. 
 | 
static java.lang.String | 
OBJECT_SID_ATTR
The Active Directory security identifier (SID) of a user. 
The SID is a unique value used to identify the user as a security principal.  | 
static java.lang.String | 
REVISION  | 
| Constructor and Description | 
|---|
LDAPUtil()  | 
| Modifier and Type | Method and Description | 
|---|---|
static boolean | 
checkConnect(java.lang.String hostname,
            java.lang.String port,
            java.lang.String isSSL,
            java.lang.String bindDN,
            java.lang.String bindPassword)
Try a LDAP connection using the given host information and credential. 
 | 
static java.lang.String | 
escapeDN(java.lang.String name)
Escape certain meta-characters in LDAP DN. 
 | 
static java.lang.String | 
escapeLDAPSearchFilter(java.lang.String filter)
Escape certain meta-characters of a name for use in LDAP search filter. 
 | 
static java.lang.String | 
extractSAMAccountName(java.lang.String login)
Retrieve the sAMAccountName from the specified login (if possible). 
 | 
static java.lang.String | 
getFirstDomainControllerHostname(java.lang.String domain)
Retrieve the first domain controler available for query for the specified windows domain. 
 | 
static LDAPUtil.SRVRecord | 
getFirstSrvRecord(java.lang.String srvRecordName)
Retrieve the first SRV record value for the specified SRV record name. 
 | 
static java.lang.String | 
getGUID(com.unboundid.ldap.sdk.Attribute objectGUIDAttribute)
Retrieve a string representation of the specified  
objectGUID LDAP attribute
 which contains a globally unique identifier assigned by Active Directory Domain 
 Services when the object instance is created.A GUID is a 128-bit number guaranteed to be unique in space and time.  | 
static byte[] | 
getGUID(java.lang.String guidStr)
Retrieve a byte array of the specified 16-byte string representation of a  
GUID. | 
static java.lang.String | 
getGUIDByteString(java.lang.String guidStr)
Retrieve a LDAP byte string representation of a  
GUID, such as \xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx. | 
static java.lang.String | 
getSid(com.unboundid.ldap.sdk.Attribute objectSidAttribute)
Retrieve a string representation of the specified  
objectSid LDAP attribute
 which contains a value that specifies the security identifier (SID) of the user.The SID is a unique value used to identify the user as a security principal.  | 
static java.util.List<LDAPUtil.SRVRecord> | 
getSrvRecords(java.lang.String srvRecordName)
Retrieve all SRV record values for the specified SRV record name. 
 | 
static java.lang.String | 
getString(com.unboundid.ldap.sdk.Attribute attribute,
         java.lang.String defaultValue)
Return first available value of  
Attribute attr, 
 or defaultValue if not available. | 
static boolean | 
isGroupEntry(com.unboundid.ldap.sdk.SearchResultEntry entry,
            LDAPConfiguration conf)
Determines if the given  
SearchResultEntry is a group entry according to parameters
 specified by the given LDAPConfiguration object. | 
static boolean | 
isUserEntry(com.unboundid.ldap.sdk.SearchResultEntry entry,
           LDAPConfiguration conf)
Determines if the given  
SearchResultEntry is a user entry according to parameters
 specified by the given LDAPConfiguration object. | 
static boolean | 
isUUID(java.lang.String str)
Check if the specified string is a 16-byte string representation of a UUID. 
 | 
public static final java.lang.String REVISION
public static final java.lang.String OBJECT_CLASS_ATTR
public static final java.lang.String OBJECT_SID_ATTR
 "objectSid"
 MSDN : Object-Sid attribute
getSid(Attribute), 
Constant Field Valuespublic static final java.lang.String OBJECT_GUID_ATTR
 "objectGUID"
 MSDN : Object-Guid attribute
getGUID(Attribute), 
Constant Field Valuespublic static java.lang.String getString(com.unboundid.ldap.sdk.Attribute attribute,
                                         java.lang.String defaultValue)
Attribute attr, 
 or defaultValue if not available.attribute - Attribute from which to retrieve value.defaultValue - the default value to use if none could be readpublic static boolean isGroupEntry(com.unboundid.ldap.sdk.SearchResultEntry entry,
                                   LDAPConfiguration conf)
SearchResultEntry is a group entry according to parameters
 specified by the given LDAPConfiguration object.entry - the SearchResultEntry to checkconf - the LDAPConfiguration to use, MUST NOT be nullpublic static boolean isUserEntry(com.unboundid.ldap.sdk.SearchResultEntry entry,
                                  LDAPConfiguration conf)
SearchResultEntry is a user entry according to parameters
 specified by the given LDAPConfiguration object.entry - the SearchResultEntry to checkconf - the LDAPConfiguration to use, MUST NOT be nullpublic static boolean checkConnect(java.lang.String hostname,
                                   java.lang.String port,
                                   java.lang.String isSSL,
                                   java.lang.String bindDN,
                                   java.lang.String bindPassword)
hostname - the hostname of the ldap server to connect to.port - the port of the ldap server to connect to.isSSL - whether the connection should be made using SSL.bindDN - the Distinguished Name to use to bind to the ldap server to connect to.bindPassword - the password to use to bind to the ldap server to connect to.public static java.lang.String escapeDN(java.lang.String name)
name - the name to escapepublic static final java.lang.String escapeLDAPSearchFilter(java.lang.String filter)
filter - the filter to escapepublic static java.lang.String extractSAMAccountName(java.lang.String login)
 Support login in Down-Level logon name formats (eg DOMAIN\sAMAccountName).
login - a user loginpublic static java.lang.String getSid(com.unboundid.ldap.sdk.Attribute objectSidAttribute)
objectSid LDAP attribute
 which contains a value that specifies the security identifier (SID) of the user.objectSidAttribute - the objectSid as retrieved frompublic static java.lang.String getFirstDomainControllerHostname(java.lang.String domain)
This methods looks for all SRV record "_ldap._tcp.dc._msdcs.{domain}" and return the first one as defined by priority and weight in all records.
domain - a windows domain namepublic static LDAPUtil.SRVRecord getFirstSrvRecord(java.lang.String srvRecordName)
srvRecordName - the name of the SRV record to query, ie "_sip._tcp.example.com."public static java.util.List<LDAPUtil.SRVRecord> getSrvRecords(java.lang.String srvRecordName)
srvRecordName - the name of the SRV record to query, ie "_sip._tcp.example.com."public static java.lang.String getGUID(com.unboundid.ldap.sdk.Attribute objectGUIDAttribute)
objectGUID LDAP attribute
 which contains a globally unique identifier assigned by Active Directory Domain 
 Services when the object instance is created.objectGUIDAttribute - the objectGUID as retrieved from ADpublic static boolean isUUID(java.lang.String str)
str - any value to checkpublic static byte[] getGUID(java.lang.String guidStr)
GUID.guidStr - 16-byte string representation of a GUID such as "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"public static java.lang.String getGUIDByteString(java.lang.String guidStr)
GUID, such as \xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx.guidStr - 16-byte string representation of a GUID such as "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"Copyright © 2001-2018 Jalios SA. All Rights Reserved.