Class LDAPDataUtil

java.lang.Object
de.xima.fc.ldap.LDAPDataUtil

public class LDAPDataUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    getAttributeList(com.unboundid.ldap.sdk.LDAPConnection connection, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String attribute)
    Returns a list of values of the passed attribute.
    static List<String>
    getDNResultList(com.unboundid.ldap.sdk.SearchResult res)
     
    static byte[]
    getObjectID(com.unboundid.ldap.sdk.SearchResultEntry entry)
     
    static byte[]
     
    static String
    getObjectIDAsString(com.unboundid.ldap.sdk.SearchResultEntry entry)
     
    static com.unboundid.ldap.sdk.Attribute
    getObjectIDAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry)
     
    static byte[]
     
    static int
    getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter)
    Returns the total count of entries that match the given filter.
    static int
    getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    static int
    getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes)
    static com.unboundid.ldap.sdk.Attribute
    getUserIdAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry, String attrName)
     
    static com.unboundid.ldap.sdk.Attribute
    getUserLoginAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry)
     
    static List<com.unboundid.ldap.sdk.SearchResult>
    searchEntries(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    Performs a query to an active directory and returns all results.
    static List<com.unboundid.ldap.sdk.SearchResult>
    searchEntries(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes)
    Performs a query to an active directory and returns all results.
    static List<com.unboundid.ldap.sdk.SearchResultEntry>
    searchEntriesFlat(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    Performs a query to an active directory and returns all flattened results.
    static List<com.unboundid.ldap.sdk.SearchResultEntry>
    searchEntriesFlat(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes)
    Performs a query to an active directory and returns all flattened results.
    static com.alibaba.fastjson.JSONArray
    searchJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes)
     
    static com.alibaba.fastjson.JSONArray
    searchJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes)
     
    searchLDAPBenutzer(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    Deprecated.
    User management has been reworked.
    searchLDAPBenutzer(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes)
    Deprecated.
    User management has been reworked.
    static List<String>
    searchLDAPGroups(com.unboundid.ldap.sdk.LDAPConnection con, String baseDn, Integer pageSize)
     
    static List<String>
    static com.alibaba.fastjson.JSONObject
    searchSingelJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    Performs a query to an active directory and returns the first result, converted to a JSON object.
    static com.alibaba.fastjson.JSONObject
    searchSingelJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, String filter, String... attributes)
    Performs a query to an active directory and returns the first result, converted to a JSON object.
    static com.unboundid.ldap.sdk.SearchResultEntry
    searchSingleEntry(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, com.unboundid.ldap.sdk.Filter filter, String... attributes)
    Performs a query to an active directory and returns the first result.
    static com.unboundid.ldap.sdk.SearchResultEntry
    searchSingleEntry(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, String filter, String... attributes)
    Performs a query to an active directory and returns the first result.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LDAPDataUtil

      public LDAPDataUtil()
  • Method Details

    • searchJSON

      public static com.alibaba.fastjson.JSONArray searchJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException, com.alibaba.fastjson.JSONException
      Throws:
      com.unboundid.ldap.sdk.LDAPException
      com.alibaba.fastjson.JSONException
    • searchJSON

      public static com.alibaba.fastjson.JSONArray searchJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException, com.alibaba.fastjson.JSONException
      Throws:
      com.unboundid.ldap.sdk.LDAPException
      com.alibaba.fastjson.JSONException
    • searchEntriesFlat

      public static List<com.unboundid.ldap.sdk.SearchResultEntry> searchEntriesFlat(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns all flattened results.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied. Otherwise, reads the result in batches by making multiple requests.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      All results that were found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchEntriesFlat

      public static List<com.unboundid.ldap.sdk.SearchResultEntry> searchEntriesFlat(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns all flattened results.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied. Otherwise, reads the result in batches by making multiple requests.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      All results that were found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchEntries

      public static List<com.unboundid.ldap.sdk.SearchResult> searchEntries(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns all results.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied and the returned list will contain exactly one entry. Otherwise, results are retrieved in batches of the given page size, and the returned list will contain {ceil(totalNumberOfResults/pageSize} entries.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      All results that were found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchEntries

      public static List<com.unboundid.ldap.sdk.SearchResult> searchEntries(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns all results.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied and the returned list will contain exactly one entry. Otherwise, results are retrieved in batches of the given page size, and the returned list will contain {ceil(totalNumberOfResults/pageSize} entries.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      All results that were found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchSingelJSON

      public static com.alibaba.fastjson.JSONObject searchSingelJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException, com.alibaba.fastjson.JSONException
      Performs a query to an active directory and returns the first result, converted to a JSON object.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      The first result that was returned, or null when no result could be found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchSingelJSON

      public static com.alibaba.fastjson.JSONObject searchSingelJSON(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException, com.alibaba.fastjson.JSONException
      Performs a query to an active directory and returns the first result, converted to a JSON object.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      The first result that was returned, or null when no result could be found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
      com.alibaba.fastjson.JSONException - When the result could not be converted to a JSON object.
    • searchSingleEntry

      public static com.unboundid.ldap.sdk.SearchResultEntry searchSingleEntry(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns the first result.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      The first result that was returned, or null when no result could be found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
    • searchSingleEntry

      public static com.unboundid.ldap.sdk.SearchResultEntry searchSingleEntry(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Performs a query to an active directory and returns the first result.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be returned. If none are given, all attributes are returned.
      Returns:
      The first result that was returned, or null when no result could be found.
      Throws:
      com.unboundid.ldap.sdk.LDAPException - When the query could not be made, such as when the filter is invalid etc.
    • getAttributeList

      public static List<String> getAttributeList(com.unboundid.ldap.sdk.LDAPConnection connection, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String attribute) throws com.unboundid.ldap.sdk.LDAPException
      Returns a list of values of the passed attribute.
      Parameters:
      connection - the current LDAPConnection
      baseDN - The base DN for the search request. It must not be null.
      scope - The scope that specifies the range of entries that should be examined for the search.
      pageSize - Size of a page
      filter - The string representation of the filter to use to identify matching entries. It must not be null.
      attribute - The LDAP attribute to retrieve
      Returns:
      List of values of the attribute
      Throws:
      com.unboundid.ldap.sdk.LDAPException - If the provided filter string cannot be parsed as an LDAP filter.
    • searchLDAPGroups

      public static List<String> searchLDAPGroups(com.unboundid.ldap.sdk.LDAPConnection con, String baseDn, Integer pageSize) throws com.unboundid.ldap.sdk.LDAPException, GeneralSecurityException
      Throws:
      com.unboundid.ldap.sdk.LDAPException
      GeneralSecurityException
    • getDNResultList

      public static List<String> getDNResultList(com.unboundid.ldap.sdk.SearchResult res)
    • getUserLoginAttribute

      public static com.unboundid.ldap.sdk.Attribute getUserLoginAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry)
    • getUserIdAttribute

      public static com.unboundid.ldap.sdk.Attribute getUserIdAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry, String attrName)
    • getTotalCount

      @Deprecated public static int getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Deprecated.
      use getTotalCount(LDAPConnection, String, SearchScope, Integer, Filter) instead. When querying the total count of entries, there is no need to specify attributes, as they are not used in the counting process.
      Returns the total count of entries that match the given filter. If paging is applied, this method will perform multiple queries to the LDAP server and sum up the counts of each page. If no paging is applied, this method will perform a single query and return the count of the returned entries.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied and the count of the returned entries is returned. Otherwise, results are retrieved in batches of the given page size, and the counts of each batch are summed up and returned.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be queried. This method will ignore the returned attributes and only return the count of the returned entries
      Returns:
      the total count of entries that match the given filter.
      Throws:
      com.unboundid.ldap.sdk.LDAPException
    • getTotalCount

      @Deprecated public static int getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Deprecated.
      use getTotalCount(LDAPConnection, String, SearchScope, Integer, Filter) instead. When querying the total count of entries, there is no need to specify attributes, as they are not used in the counting process.
      Returns the total count of entries that match the given filter. If paging is applied, this method will perform multiple queries to the LDAP server and sum up the counts of each page. If no paging is applied, this method will perform a single query and return the count of the returned entries.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied and the count of the returned entries is returned. Otherwise, results are retrieved in batches of the given page size, and the counts of each batch are summed up and returned.
      filter - A filter for limiting the search results.
      attributes - An optional list of attributes that should be queried. This method will ignore the returned attributes and only return the count of the returned entries
      Returns:
      the total count of entries that match the given filter.
      Throws:
      com.unboundid.ldap.sdk.LDAPException
    • getTotalCount

      public static int getTotalCount(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter) throws com.unboundid.ldap.sdk.LDAPException
      Returns the total count of entries that match the given filter. If paging is applied, this method will perform multiple queries to the LDAP server and sum up the counts of each page. If no paging is applied, this method will perform a single query and return the count of the returned entries. This method uses the SearchRequest.NO_ATTRIBUTES constant to indicate that no attributes should be returned, as they are not used in the counting process.
      Parameters:
      con - Connection to the active directory.
      baseDN - Base DN where to start the search.
      scope - The scope for the search.
      pageSize - If null or less than or equal to 0, no paging is applied and the count of the returned entries is returned. Otherwise, results are retrieved in batches of the given page size, and the counts of each batch are summed up and returned.
      filter - A filter for limiting the search results.
      Throws:
      com.unboundid.ldap.sdk.LDAPException
    • getObjectIDAsString

      public static String getObjectIDAsString(com.unboundid.ldap.sdk.SearchResultEntry entry)
    • getObjectIDAttribute

      public static com.unboundid.ldap.sdk.Attribute getObjectIDAttribute(com.unboundid.ldap.sdk.SearchResultEntry entry)
    • getObjectIDAttribute

      public static byte[] getObjectIDAttribute(Map<String,Object> attributes) throws ParseException
      Throws:
      ParseException
    • getObjectID

      public static byte[] getObjectID(Map<String,Object> attributes)
    • getObjectID

      public static byte[] getObjectID(com.unboundid.ldap.sdk.SearchResultEntry entry)
    • searchLDAPGroups

      @Deprecated public static List<String> searchLDAPGroups(LDAPGruppe gruppe, MandantLdapData data) throws com.unboundid.ldap.sdk.LDAPException, GeneralSecurityException
      Throws:
      com.unboundid.ldap.sdk.LDAPException
      GeneralSecurityException
    • searchLDAPBenutzer

      @Deprecated public static List<LDAPBenutzer> searchLDAPBenutzer(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, String filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Deprecated.
      User management has been reworked. Users may have multiple identities to sign in with.
      Throws:
      com.unboundid.ldap.sdk.LDAPException
    • searchLDAPBenutzer

      @Deprecated public static List<LDAPBenutzer> searchLDAPBenutzer(com.unboundid.ldap.sdk.LDAPConnection con, String baseDN, com.unboundid.ldap.sdk.SearchScope scope, Integer pageSize, com.unboundid.ldap.sdk.Filter filter, String... attributes) throws com.unboundid.ldap.sdk.LDAPException
      Deprecated.
      User management has been reworked. Users may have multiple identities to sign in with.
      Throws:
      com.unboundid.ldap.sdk.LDAPException