use of org.keycloak.storage.ldap.idm.query.internal.LDAPQuery in project keycloak by keycloak.
the class LDAPStorageProvider method loadLDAPUserByUuid.
public LDAPObject loadLDAPUserByUuid(RealmModel realm, String uuid) {
if (uuid == null) {
return null;
}
try (LDAPQuery ldapQuery = LDAPUtils.createQueryForUserSearch(this, realm)) {
LDAPQueryConditionsBuilder conditionsBuilder = new LDAPQueryConditionsBuilder();
String uuidLDAPAttributeName = this.ldapIdentityStore.getConfig().getUuidLDAPAttributeName();
Condition usernameCondition = conditionsBuilder.equal(uuidLDAPAttributeName, uuid, EscapeStrategy.DEFAULT);
ldapQuery.addWhereCondition(usernameCondition);
return ldapQuery.getFirstResult();
}
}
use of org.keycloak.storage.ldap.idm.query.internal.LDAPQuery in project keycloak by keycloak.
the class LDAPStorageProvider method loadLDAPUserByUsername.
public LDAPObject loadLDAPUserByUsername(RealmModel realm, String username) {
try (LDAPQuery ldapQuery = LDAPUtils.createQueryForUserSearch(this, realm)) {
LDAPQueryConditionsBuilder conditionsBuilder = new LDAPQueryConditionsBuilder();
String usernameMappedAttribute = this.ldapIdentityStore.getConfig().getUsernameLdapAttribute();
Condition usernameCondition = conditionsBuilder.equal(usernameMappedAttribute, username, EscapeStrategy.DEFAULT);
ldapQuery.addWhereCondition(usernameCondition);
LDAPObject ldapUser = ldapQuery.getFirstResult();
if (ldapUser == null) {
return null;
}
return ldapUser;
}
}
use of org.keycloak.storage.ldap.idm.query.internal.LDAPQuery in project keycloak by keycloak.
the class GroupLDAPStorageMapper method loadLDAPGroupByName.
public LDAPObject loadLDAPGroupByName(String groupName) {
try (LDAPQuery ldapQuery = createGroupQuery(true)) {
Condition roleNameCondition = new LDAPQueryConditionsBuilder().equal(config.getGroupNameLdapAttribute(), groupName);
ldapQuery.addWhereCondition(roleNameCondition);
return ldapQuery.getFirstResult();
}
}
use of org.keycloak.storage.ldap.idm.query.internal.LDAPQuery in project keycloak by keycloak.
the class RoleLDAPStorageMapper method loadLDAPRoleByName.
public LDAPObject loadLDAPRoleByName(String roleName) {
try (LDAPQuery ldapQuery = createRoleQuery(true)) {
Condition roleNameCondition = new LDAPQueryConditionsBuilder().equal(config.getRoleNameLdapAttribute(), roleName);
ldapQuery.addWhereCondition(roleNameCondition);
return ldapQuery.getFirstResult();
}
}
use of org.keycloak.storage.ldap.idm.query.internal.LDAPQuery in project keycloak by keycloak.
the class LDAPTestUtils method removeAllLDAPRoles.
public static void removeAllLDAPRoles(KeycloakSession session, RealmModel appRealm, ComponentModel ldapModel, String mapperName) {
ComponentModel mapperModel = getSubcomponentByName(appRealm, ldapModel, mapperName);
LDAPStorageProvider ldapProvider = LDAPTestUtils.getLdapProvider(session, ldapModel);
try (LDAPQuery roleQuery = getRoleMapper(mapperModel, ldapProvider, appRealm).createRoleQuery(false)) {
List<LDAPObject> ldapRoles = roleQuery.getResultList();
for (LDAPObject ldapRole : ldapRoles) {
ldapProvider.getLdapIdentityStore().remove(ldapRole);
}
}
}
Aggregations