LDAP: fix regression on iCal 3 search completion

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1434 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-09 19:30:25 +00:00
parent 51bad68fb5
commit b8e4570681
2 changed files with 14 additions and 1 deletions

View File

@ -318,6 +318,12 @@ public class DavExchangeSession extends ExchangeSession {
buildGalfindContact(contact, result);
if (needGalLookup(searchAttributeName, returningAttributes)) {
galLookup(contact);
// iCal fix to suit both iCal 3 and 4: move cn to sn, remove cn
} else if (returningAttributes.contains("apple-serviceslocator")) {
if (contact.get("cn") != null && returningAttributes.contains("sn")) {
contact.put("sn", contact.get("cn"));
contact.remove("cn");
}
}
if (condition.isMatch(contact)) {
contacts.put(contact.getName().toLowerCase(), contact);

View File

@ -22,7 +22,6 @@ import davmail.DavGateway;
import davmail.Settings;
import davmail.exchange.AbstractExchangeSessionTestCase;
import davmail.exchange.ExchangeSessionFactory;
import org.apache.log4j.Level;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@ -138,4 +137,12 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
searchControls.setReturningAttributes(new String[]{"sn"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(cn=*)", searchControls);
}
public void testSearchByCnReturnGivenName() throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
searchControls.setReturningAttributes(new String[]{"givenName"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(cn=*a*)", searchControls);
}
}