/** * Checks the bean injection. * * @throws Exception * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ public void afterPropertiesSet() throws Exception { Assert.notNull( this.parametersProvider, "The property parametersProvider in the class " + this.getClass().getName() + " can't be null."); Assert.notNull( this.connectionManager, "The property connectionManager in the class " + this.getClass().getName() + " can't be null."); ldapParameters = (PersonsParametersSection) parametersProvider.getPersonsParametersSection(); uidAttributeArray = new String[] {ldapParameters.getLdapUidAttribute()}; connection = connectionManager.connect(); constraints = new LDAPSearchConstraints(); constraints.setMaxResults(0); }
/** * Gives the members, in the ldap, that are corresponding to the logic definition of a group. * * @param definition The logic definition of the members of the group. * @return The set of the members ids. * @see * org.esco.dynamicgroups.dao.ldap.IMembersFromDefinitionDAO#getMembers(DynamicGroupDefinition) */ public Set<String> getMembers(final DynamicGroupDefinition definition) { final Set<String> userIds = new HashSet<String>(); if (definition.isValid()) { checkConnection(); final String filter = translateToLdapFilter(definition); try { final LDAPSearchResults result = getConnection() .search( ldapParameters.getLdapSearchBase(), LDAPConnection.SCOPE_SUB, filter, uidAttributeArray, false, constraints); while (result.hasMore()) { final LDAPEntry entry = result.next(); userIds.add(entry.getAttribute(ldapParameters.getLdapUidAttribute()).getStringValue()); } } catch (LDAPException e) { LOGGER.error( "Error while trying to retrieve the members for the definition: " + definition + " - associated filter: " + filter); LOGGER.error(e, e); final String filter2 = translateToLdapFilter(definition); LOGGER.error("!!! Remove this message : " + filter2); } } return userIds; }