public List<LdapUser> getUsersFromGroup(int maximum, LdapGroup group) throws NamingException { List<LdapUser> users = new ArrayList<>(); final String mapping = settings.getGroupMemberMapping(); javax.naming.directory.Attribute members = group. getMappedAttribute(mapping); if (members == null) { return users; } NamingEnumeration<?> results = members.getAll(); while (results.hasMoreElements() && users.size() < maximum) { try { final String userDN = (String) results.next(); LdapUser user = getUserByDNAndFilter(userDN, settings. getUserFilter()); if (user != null) { users.add(user); } } catch (LdapReferralException ex) { logger.warn(ex.getMessage(), ex); } } Collections.sort(users, new LdapUserComparator()); return users; }
private int countLdapEntities(int maximum, final String baseDN, final String preferredFilter) throws NamingException { if (maximum <= 0) { return 0; } int count = 0; NamingEnumeration<SearchResult> results = searchLDAP(baseDN, preferredFilter); while (results.hasMoreElements() && count < maximum) { try { results.next(); count++; } catch (LdapReferralException ex) { logger.warn(ex.getMessage(), ex); } } return count; }
public void testAllCoveragePurpose() throws NamingException { log.setMethod("testAllCoveragePurpose()"); LdapReferralException ex = new MockLdapReferralException(); ex = new MockLdapReferralException("message"); ex.getReferralContext(); ex.getReferralContext(null); ex.getReferralContext(null, null); ex.getReferralInfo(); ex.skipReferral(); ex.retryReferral(); }