Class MSADUserAccountControlStorageMapper

java.lang.Object
org.keycloak.storage.ldap.mappers.AbstractLDAPStorageMapper
org.keycloak.storage.ldap.mappers.msad.MSADUserAccountControlStorageMapper
All Implemented Interfaces:
org.keycloak.provider.Provider, LDAPStorageMapper, PasswordUpdateCallback

public class MSADUserAccountControlStorageMapper extends AbstractLDAPStorageMapper implements PasswordUpdateCallback
Mapper specific to MSAD. It's able to read the userAccountControl and pwdLastSet attributes and set actions in Keycloak based on that. It's also able to handle exception code from LDAP user authentication (See http://www-01.ibm.com/support/docview.wss?uid=swg21290631 )
Author:
Marek Posolda
  • Field Details

    • LDAP_PASSWORD_POLICY_HINTS_ENABLED

      public static final String LDAP_PASSWORD_POLICY_HINTS_ENABLED
      See Also:
    • ALWAYS_READ_ENABLED_VALUE_FROM_LDAP

      public static final String ALWAYS_READ_ENABLED_VALUE_FROM_LDAP
      See Also:
    • PASSWORD_UPDATE_LDAP_ERROR_CODES

      public static final Set<String> PASSWORD_UPDATE_LDAP_ERROR_CODES
    • PASSWORD_UPDATE_MSAD_ERROR_CODES

      public static final Set<String> PASSWORD_UPDATE_MSAD_ERROR_CODES
  • Constructor Details

    • MSADUserAccountControlStorageMapper

      public MSADUserAccountControlStorageMapper(org.keycloak.component.ComponentModel mapperModel, LDAPStorageProvider ldapProvider)
  • Method Details

    • beforeLDAPQuery

      public void beforeLDAPQuery(LDAPQuery query)
      Description copied from interface: LDAPStorageMapper
      Called before LDAP Identity query for retrieve LDAP users was executed. It allows to change query somehow (add returning attributes from LDAP, change conditions etc)
      Specified by:
      beforeLDAPQuery in interface LDAPStorageMapper
    • beforePasswordUpdate

      public LDAPOperationDecorator beforePasswordUpdate(org.keycloak.models.UserModel user, LDAPObject ldapUser, org.keycloak.models.UserCredentialModel password)
      Specified by:
      beforePasswordUpdate in interface PasswordUpdateCallback
    • passwordUpdated

      public void passwordUpdated(org.keycloak.models.UserModel user, LDAPObject ldapUser, org.keycloak.models.UserCredentialModel password)
      Specified by:
      passwordUpdated in interface PasswordUpdateCallback
    • passwordUpdateFailed

      public void passwordUpdateFailed(org.keycloak.models.UserModel user, LDAPObject ldapUser, org.keycloak.models.UserCredentialModel password, org.keycloak.models.ModelException exception)
      Specified by:
      passwordUpdateFailed in interface PasswordUpdateCallback
    • proxy

      public org.keycloak.models.UserModel proxy(LDAPObject ldapUser, org.keycloak.models.UserModel delegate, org.keycloak.models.RealmModel realm)
      Description copied from interface: LDAPStorageMapper
      Called when invoke proxy on LDAP federation provider
      Specified by:
      proxy in interface LDAPStorageMapper
      Returns:
    • onRegisterUserToLDAP

      public void onRegisterUserToLDAP(LDAPObject ldapUser, org.keycloak.models.UserModel localUser, org.keycloak.models.RealmModel realm)
      Description copied from interface: LDAPStorageMapper
      Called when register new user to LDAP - just after user was created in Keycloak DB
      Specified by:
      onRegisterUserToLDAP in interface LDAPStorageMapper
    • onImportUserFromLDAP

      public void onImportUserFromLDAP(LDAPObject ldapUser, org.keycloak.models.UserModel user, org.keycloak.models.RealmModel realm, boolean isCreate)
      Description copied from interface: LDAPStorageMapper
      Called when importing user from LDAP to local keycloak DB.
      Specified by:
      onImportUserFromLDAP in interface LDAPStorageMapper
      isCreate - true if we importing new user from LDAP. False if user already exists in Keycloak, but we are upgrading (syncing) it from LDAP
    • onAuthenticationFailure

      public boolean onAuthenticationFailure(LDAPObject ldapUser, org.keycloak.models.UserModel user, AuthenticationException ldapException, org.keycloak.models.RealmModel realm)
      Description copied from interface: LDAPStorageMapper
      Called when LDAP authentication of specified user fails. If any mapper returns true from this method, AuthenticationException won't be rethrown!
      Specified by:
      onAuthenticationFailure in interface LDAPStorageMapper
      Overrides:
      onAuthenticationFailure in class AbstractLDAPStorageMapper
      Returns:
      true if mapper processed the AuthenticationException and did some actions based on that. In that case, AuthenticationException won't be rethrown!
    • processAuthErrorCode

      protected boolean processAuthErrorCode(String errorCode, org.keycloak.models.UserModel user)
    • processFailedPasswordUpdateException

      protected org.keycloak.models.ModelException processFailedPasswordUpdateException(org.keycloak.models.ModelException e)
    • getUserAccountControl

      protected UserAccountControl getUserAccountControl(LDAPObject ldapUser)
    • updateUserAccountControl

      protected void updateUserAccountControl(boolean updateInLDAP, LDAPObject ldapUser, UserAccountControl accountControl)