org.keycloak.federation.ldap

## Class LDAPUtils

- java.lang.Object
- - org.keycloak.federation.ldap.LDAPUtils

-     public class LDAPUtils
      extends Object

  Allow to directly call some operations against LDAPIdentityStore.
  Author:
    Marek Posolda

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LDAPUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addMember(LDAPFederationProvider ldapProvider, MembershipType membershipType, String memberAttrName, LDAPObject ldapParent, LDAPObject ldapChild, boolean sendLDAPUpdateRequest)` Add ldapChild as member of ldapParent and save ldapParent to LDAP.
    `static LDAPObject` | `addUserToLDAP(LDAPFederationProvider ldapProvider, RealmModel realm, UserModel user)`
    `static void` | `checkUuid(LDAPObject ldapUser, LDAPConfig config)`
    `static LDAPObject` | `createLDAPGroup(LDAPFederationProvider ldapProvider, String groupName, String groupNameAttribute, Collection<String> objectClasses, String parentDn, Map<String,Set<String>> additionalAttributes)`
    `static LDAPQuery` | `createQueryForUserSearch(LDAPFederationProvider ldapProvider, RealmModel realm)`
    `static void` | `deleteMember(LDAPFederationProvider ldapProvider, MembershipType membershipType, String memberAttrName, LDAPObject ldapParent, LDAPObject ldapChild, boolean sendLDAPUpdateRequest)` Remove ldapChild as member of ldapParent and save ldapParent to LDAP.
    `static Set<String>` | `getExistingMemberships(String memberAttrName, LDAPObject ldapRole)` Return all existing memberships (values of attribute 'member' ) from the given ldapRole or ldapGroup
    `static String` | `getMemberValueOfChildObject(LDAPObject ldapUser, MembershipType membershipType)` Get value to be used as attribute 'member' in some parent ldapObject
    `static String` | `getUsername(LDAPObject ldapUser, LDAPConfig config)`
    `static List<LDAPObject>` | `loadAllLDAPObjects(LDAPQuery ldapQuery, LDAPFederationProvider ldapProvider)` Load all LDAP objects corresponding to given query.
    `static void` | `validateCustomLdapFilter(String customFilter)` Validate configured customFilter matches the requested format

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LDAPUtils

          public LDAPUtils()

  - ### Method Detail

    - #### addUserToLDAP

          public static LDAPObject addUserToLDAP(LDAPFederationProvider ldapProvider,
                                                 RealmModel realm,
                                                 UserModel user)

      Parameters:
        `ldapProvider` -
        `realm` -
        `user` -
      Returns:
        newly created LDAPObject with all the attributes, uuid and DN properly set

    - #### createQueryForUserSearch

          public static LDAPQuery createQueryForUserSearch(LDAPFederationProvider ldapProvider,
                                                           RealmModel realm)

    - #### getUsername

          public static String getUsername(LDAPObject ldapUser,
                                           LDAPConfig config)

    - #### checkUuid

          public static void checkUuid(LDAPObject ldapUser,
                                       LDAPConfig config)

    - #### createLDAPGroup

          public static LDAPObject createLDAPGroup(LDAPFederationProvider ldapProvider,
                                                   String groupName,
                                                   String groupNameAttribute,
                                                   Collection<String> objectClasses,
                                                   String parentDn,
                                                   Map<String,Set<String>> additionalAttributes)

    - #### addMember

          public static void addMember(LDAPFederationProvider ldapProvider,
                                       MembershipType membershipType,
                                       String memberAttrName,
                                       LDAPObject ldapParent,
                                       LDAPObject ldapChild,
                                       boolean sendLDAPUpdateRequest)

      Add ldapChild as member of ldapParent and save ldapParent to LDAP.
      Parameters:
        `ldapProvider` -
        `membershipType` - how is 'member' attribute saved (full DN or just uid)
        `memberAttrName` - usually 'member'
        `ldapParent` - role or group
        `ldapChild` - usually user (or child group or child role)
        `sendLDAPUpdateRequest` - if true, the method will send LDAP update request too. Otherwise it will skip it

    - #### deleteMember

          public static void deleteMember(LDAPFederationProvider ldapProvider,
                                          MembershipType membershipType,
                                          String memberAttrName,
                                          LDAPObject ldapParent,
                                          LDAPObject ldapChild,
                                          boolean sendLDAPUpdateRequest)

      Remove ldapChild as member of ldapParent and save ldapParent to LDAP.
      Parameters:
        `ldapProvider` -
        `membershipType` - how is 'member' attribute saved (full DN or just uid)
        `memberAttrName` - usually 'member'
        `ldapParent` - role or group
        `ldapChild` - usually user (or child group or child role)
        `sendLDAPUpdateRequest` - if true, the method will send LDAP update request too. Otherwise it will skip it

    - #### getExistingMemberships

          public static Set<String> getExistingMemberships(String memberAttrName,
                                                           LDAPObject ldapRole)

      Return all existing memberships (values of attribute 'member' ) from the given ldapRole or ldapGroup
      Parameters:
        `memberAttrName` - usually 'member'
        `ldapRole` -
      Returns:

    - #### getMemberValueOfChildObject

          public static String getMemberValueOfChildObject(LDAPObject ldapUser,
                                                           MembershipType membershipType)

      Get value to be used as attribute 'member' in some parent ldapObject

    - #### loadAllLDAPObjects

          public static List<LDAPObject> loadAllLDAPObjects(LDAPQuery ldapQuery,
                                                            LDAPFederationProvider ldapProvider)

      Load all LDAP objects corresponding to given query. We will load them paginated, so we allow to bypass the limitation of 1000 maximum loaded objects in single query in MSAD
      Parameters:
        `ldapQuery` -
        `ldapProvider` -
      Returns:

    - #### validateCustomLdapFilter

          public static void validateCustomLdapFilter(String customFilter)
                                               throws FederationConfigValidationException

      Validate configured customFilter matches the requested format
      Parameters:
        `customFilter` -
      Throws:
        `FederationConfigValidationException`

Copyright © 2016 JBoss by Red Hat. All rights reserved.