mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
LDAP: avoid galLookup in iCal searches
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1366 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
77f05c88f3
commit
b5f79aafe3
@ -326,16 +326,14 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean needGalLookup(String searchAttributeName, Set<String> returningAttributes) {
|
protected boolean needGalLookup(String searchAttributeName, Set<String> returningAttributes) {
|
||||||
// search attribute is gallookup attribute, need to fetch value for isMatch
|
// return all attributes => call gallookup
|
||||||
if (GALLOOKUP_ATTRIBUTES.contains(searchAttributeName)) {
|
if (returningAttributes == null || returningAttributes.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (returningAttributes == null) {
|
// iCal search, do not call gallookup
|
||||||
return true;
|
|
||||||
// iCal search, do not call gallookup
|
|
||||||
} else if (returningAttributes.contains("apple-serviceslocator")) {
|
} else if (returningAttributes.contains("apple-serviceslocator")) {
|
||||||
return false;
|
return false;
|
||||||
// return all attributes => call gallookup
|
// search attribute is gallookup attribute, need to fetch value for isMatch
|
||||||
} else if (returningAttributes.isEmpty()) {
|
} else if (GALLOOKUP_ATTRIBUTES.contains(searchAttributeName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,13 +792,19 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
public boolean isMatch(ExchangeSession.Contact contact) {
|
public boolean isMatch(ExchangeSession.Contact contact) {
|
||||||
String lowerCaseValue = value.toLowerCase();
|
String lowerCaseValue = value.toLowerCase();
|
||||||
String actualValue = contact.get(attributeName);
|
String actualValue = contact.get(attributeName);
|
||||||
|
Operator actualOperator = operator;
|
||||||
|
// patch for iCal search without galLookup
|
||||||
|
if (actualValue == null && ("givenName".equals(attributeName) || "sn".equals(attributeName))) {
|
||||||
|
actualValue = contact.get("cn");
|
||||||
|
actualOperator = Operator.Like;
|
||||||
|
}
|
||||||
if (actualValue == null) {
|
if (actualValue == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
actualValue = actualValue.toLowerCase();
|
actualValue = actualValue.toLowerCase();
|
||||||
return (operator == Operator.IsEqualTo && actualValue.equals(lowerCaseValue)) ||
|
return (actualOperator == Operator.IsEqualTo && actualValue.equals(lowerCaseValue)) ||
|
||||||
(operator == Operator.Like && actualValue.contains(lowerCaseValue)) ||
|
(actualOperator == Operator.Like && actualValue.contains(lowerCaseValue)) ||
|
||||||
(operator == Operator.StartsWith && actualValue.startsWith(lowerCaseValue));
|
(actualOperator == Operator.StartsWith && actualValue.startsWith(lowerCaseValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,8 +228,10 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
|
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("labeleduri", 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-generateduid", null);
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("apple-serviceslocator", null);
|
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("uidnumber", null);
|
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("uidnumber", null);
|
||||||
|
|
||||||
|
// iCal search attribute
|
||||||
|
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("apple-serviceslocator", "apple-serviceslocator");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1417,6 +1419,7 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
Map<String, ExchangeSession.Contact> results = new HashMap<String, ExchangeSession.Contact>();
|
Map<String, ExchangeSession.Contact> results = new HashMap<String, ExchangeSession.Contact>();
|
||||||
|
|
||||||
Set<String> contactReturningAttributes = convertLdapToContactReturningAttributes(returningAttributes);
|
Set<String> contactReturningAttributes = convertLdapToContactReturningAttributes(returningAttributes);
|
||||||
|
contactReturningAttributes.remove("apple-serviceslocator");
|
||||||
List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, contactReturningAttributes, condition, maxCount);
|
List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, contactReturningAttributes, condition, maxCount);
|
||||||
|
|
||||||
for (ExchangeSession.Contact contact : contacts) {
|
for (ExchangeSession.Contact contact : contacts) {
|
||||||
|
@ -106,7 +106,7 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
|
|||||||
assertTrue(searchResults.hasMore());
|
assertTrue(searchResults.hasMore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAnotherOSXSearch() throws NamingException {
|
public void testOSXICalSearch() throws NamingException {
|
||||||
SearchControls searchControls = new SearchControls();
|
SearchControls searchControls = new SearchControls();
|
||||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||||
searchControls.setReturningAttributes(new String[]{"uid", "mail", "sn", "cn", "description", "apple-generateduid", "givenname", "apple-serviceslocator", "uidnumber"});
|
searchControls.setReturningAttributes(new String[]{"uid", "mail", "sn", "cn", "description", "apple-generateduid", "givenname", "apple-serviceslocator", "uidnumber"});
|
||||||
|
Loading…
Reference in New Issue
Block a user