com.stratelia.silverpeas.domains.ldapdriver
Class LDAPUtility

java.lang.Object
  extended by com.stratelia.silverpeas.domains.ldapdriver.LDAPUtility

public class LDAPUtility
extends Object

This class contains some usefull static functions to access to LDAP elements

Author:
tleroi

Field Summary
static String BASEDN_SEPARATOR
           
static int MAX_NB_RETRY_CONNECT
           
static int MAX_NB_RETRY_TIMELIMIT
           
 
Constructor Summary
LDAPUtility()
           
 
Method Summary
static void closeConnection(String connectionId)
          Method declaration
static String dblBackSlashesForDNInFilters(String theDN)
           
static String escapeDN(String name)
          Escaping DN to prevent LDAP injection.
static String[] getAttributeValues(com.novell.ldap.LDAPEntry theEntry, String theAttributeName)
          Reads the values of an attribute and return the strings
static com.novell.ldap.LDAPConnection getConnection(String connectionId)
          Method declaration
static String getFirstAttributeValue(com.novell.ldap.LDAPEntry theEntry, String attributeName)
          Returns the first value of a specific attribute from an entry.
static com.novell.ldap.LDAPEntry getFirstEntryFromSearch(String lds, String baseDN, int scope, String filter, String[] attrs)
          Search and returns the first Entry that match the parameters baseDN, scope and filter
static AbstractLDAPTimeStamp getTimeStamp(String lds, String baseDN, int scope, String filter, String timeStampVar, String minTimeStamp)
           
static boolean isAGuid(String attName)
           
static String normalizeFilterValue(String theFilter)
           
static String openConnection(LDAPSettings driverSettings)
          Method declaration
static boolean recoverConnection(String connectionId, com.novell.ldap.LDAPException ex)
          Method declaration
static com.novell.ldap.LDAPEntry[] search1000Plus(String lds, String baseDN, int scope, String filter, String varToSort, String[] args)
          Method declaration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NB_RETRY_CONNECT

public static final int MAX_NB_RETRY_CONNECT
See Also:
Constant Field Values

MAX_NB_RETRY_TIMELIMIT

public static final int MAX_NB_RETRY_TIMELIMIT
See Also:
Constant Field Values

BASEDN_SEPARATOR

public static final String BASEDN_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

LDAPUtility

public LDAPUtility()
Method Detail

openConnection

public static String openConnection(LDAPSettings driverSettings)
                             throws AdminException
Method declaration

Parameters:
driverSettings -
Returns:
Throws:
AdminException
See Also:

getConnection

public static com.novell.ldap.LDAPConnection getConnection(String connectionId)
Method declaration

Parameters:
connectionId -
Returns:
Throws:
AdminException
See Also:

recoverConnection

public static boolean recoverConnection(String connectionId,
                                        com.novell.ldap.LDAPException ex)
Method declaration

Parameters:
connectionId -
ex -
Returns:
Throws:
AdminException
See Also:

closeConnection

public static void closeConnection(String connectionId)
                            throws AdminException
Method declaration

Parameters:
connectionId -
Throws:
AdminException
See Also:

getFirstAttributeValue

public static String getFirstAttributeValue(com.novell.ldap.LDAPEntry theEntry,
                                            String attributeName)
Returns the first value of a specific attribute from an entry. If this attribute have multiple values, only the first is returned

Parameters:
theEntry - the LDAP entry
attributeName - the name of the attribute to retreive
Returns:
the first value as a string

getFirstEntryFromSearch

public static com.novell.ldap.LDAPEntry getFirstEntryFromSearch(String lds,
                                                                String baseDN,
                                                                int scope,
                                                                String filter,
                                                                String[] attrs)
                                                         throws AdminException
Search and returns the first Entry that match the parameters baseDN, scope and filter

Parameters:
lds - the LDAP connection name
baseDN - the base DN for the search
scope - the scope (LDAPConnection.SCOPE_BASE, LDAPConnection.SCOPE_ONE or LDAPConnection.SCOPE_SUB)
filter - the filter for the search (if null, use '(objectClass=*)' )
attrs - hidden attributes
Returns:
the first entry found
Throws:
AdminException - if a problem occur

isAGuid

public static boolean isAGuid(String attName)

getAttributeValues

public static String[] getAttributeValues(com.novell.ldap.LDAPEntry theEntry,
                                          String theAttributeName)
Reads the values of an attribute and return the strings

Parameters:
theEntry - entry to read the attribute
theAttributeName - name of the attribute to retreive
Returns:
the attribute's values as string

dblBackSlashesForDNInFilters

public static String dblBackSlashesForDNInFilters(String theDN)

normalizeFilterValue

public static String normalizeFilterValue(String theFilter)

escapeDN

public static String escapeDN(String name)
Escaping DN to prevent LDAP injection. Based on http://blogs.sun.com/shankar/entry/what_is_ldap_injection

Parameters:
name - the DN to be espaced.
Returns:
the escaped DN.

search1000Plus

public static com.novell.ldap.LDAPEntry[] search1000Plus(String lds,
                                                         String baseDN,
                                                         int scope,
                                                         String filter,
                                                         String varToSort,
                                                         String[] args)
                                                  throws AdminException
Method declaration

Parameters:
lds -
baseDN -
scope -
filter -
varToSort -
args -
Returns:
Throws:
AdminException
See Also:

getTimeStamp

public static AbstractLDAPTimeStamp getTimeStamp(String lds,
                                                 String baseDN,
                                                 int scope,
                                                 String filter,
                                                 String timeStampVar,
                                                 String minTimeStamp)
                                          throws AdminException
Throws:
AdminException


Copyright © 2016 Silverpeas. All Rights Reserved.