diff --git a/src/java/davmail/ldap/LdapConnection.java b/src/java/davmail/ldap/LdapConnection.java index 463cbdd1..d26eca4d 100644 --- a/src/java/davmail/ldap/LdapConnection.java +++ b/src/java/davmail/ldap/LdapConnection.java @@ -291,7 +291,9 @@ public class LdapConnection extends AbstractConnection { LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillahomestreet2", null); LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("labeleduri", null); - + LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("apple-generateduid", null); + LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("apple-serviceslocator", null); + LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("uidnumber", null); } /** @@ -963,7 +965,11 @@ public class LdapConnection extends AbstractConnection { Map persons = null; for (LdapFilter child : criteria) { - Map childFind = child.findInGAL(session, returningAttributes, sizeLimit); + int currentSizeLimit = sizeLimit; + if (persons != null) { + currentSizeLimit -= persons.size(); + } + Map childFind = child.findInGAL(session, returningAttributes, currentSizeLimit); if (childFind != null) { if (persons == null) { @@ -1319,7 +1325,7 @@ public class LdapConnection extends AbstractConnection { } } if (!abandon && persons.size() < sizeLimit) { - for (ExchangeSession.Contact person : ldapFilter.findInGAL(session, returningAttributes, sizeLimit).values()) { + for (ExchangeSession.Contact person : ldapFilter.findInGAL(session, returningAttributes, sizeLimit - persons.size()).values()) { if (persons.size() == sizeLimit) { break; } diff --git a/src/test/davmail/ldap/TestLdap.java b/src/test/davmail/ldap/TestLdap.java index 605af57a..e17ff807 100644 --- a/src/test/davmail/ldap/TestLdap.java +++ b/src/test/davmail/ldap/TestLdap.java @@ -98,4 +98,20 @@ public class TestLdap extends AbstractExchangeSessionTestCase { assertEquals(session.getAlias(), attribute.get()); assertNotNull(attributes.get("givenName")); } + + public void testOSXSearch() throws NamingException { + SearchControls searchControls = new SearchControls(); + searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE); + searchControls.setReturningAttributes(new String[]{"uid", "jpegphoto", "postalcode", "mail", "sn", "apple-emailcontacts", "c", "street", "givenname", "l", "apple-user-picture", "telephonenumber", "cn", "st", "apple-imhandle"}); + NamingEnumeration searchResults = ldapContext.search("cn=users, o=od", "(&(objectclass=inetOrgPerson)(|(givenname=Charles*)(|(uid=Charles*)(cn=Charles*))(sn=Charles*))(objectclass=shadowAccount)(objectclass=extensibleObject)(objectclass=posixAccount)(objectclass=apple-user))", searchControls); + assertTrue(searchResults.hasMore()); + } + + public void testAnotherOSXSearch() throws NamingException { + SearchControls searchControls = new SearchControls(); + searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE); + searchControls.setReturningAttributes(new String[]{"uid", "mail", "sn", "cn", "description", "apple-generateduid", "givenname", "apple-serviceslocator", "uidnumber"}); + NamingEnumeration searchResults = ldapContext.search("cn=users, o=od", + "(&(objectclass=inetOrgPerson)(objectclass=extensibleObject)(objectclass=apple-user)(|(|(uid=fair*)(cn=fair*))(givenname=fair*)(sn=fair*)(cn=fair*)(mail=fair*))(objectclass=posixAccount)(objectclass=shadowAccount))", searchControls); + } }