mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
LDAP: improve EWS filter support
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1426 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
f944efe43d
commit
39079d3719
@ -149,7 +149,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
|
||||
protected static class AutoDiscoverMethod extends PostMethod {
|
||||
AutoDiscoverMethod(String autodiscoverHost, String userEmail) {
|
||||
super("https://"+autodiscoverHost+"/autodiscover/autodiscover.xml");
|
||||
super("https://" + autodiscoverHost + "/autodiscover/autodiscover.xml");
|
||||
setAutoDiscoverRequestEntity(userEmail);
|
||||
}
|
||||
|
||||
@ -529,6 +529,16 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
// encode urlcompname
|
||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
||||
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
||||
} else if (fieldURI instanceof ExtendedFieldURI
|
||||
&& ((ExtendedFieldURI) fieldURI).propertyType == ExtendedFieldURI.PropertyType.Integer) {
|
||||
// check value
|
||||
try {
|
||||
Integer.parseInt(value);
|
||||
buffer.append(value);
|
||||
} catch (NumberFormatException e) {
|
||||
// invalid value, replace with 0
|
||||
buffer.append('0');
|
||||
}
|
||||
} else {
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
}
|
||||
@ -1487,7 +1497,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
protected static final HashMap<String, String> GALFIND_ATTRIBUTE_MAP = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
GALFIND_ATTRIBUTE_MAP.put("uid", "Name");
|
||||
GALFIND_ATTRIBUTE_MAP.put("imapUid", "Name");
|
||||
GALFIND_ATTRIBUTE_MAP.put("cn", "DisplayName");
|
||||
GALFIND_ATTRIBUTE_MAP.put("givenName", "GivenName");
|
||||
GALFIND_ATTRIBUTE_MAP.put("sn", "Surname");
|
||||
@ -1499,7 +1509,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
protected Contact buildGalfindContact(EWSMethod.Item response) {
|
||||
Contact contact = new Contact();
|
||||
contact.setName(response.get("Name"));
|
||||
contact.put("uid", response.get("Name"));
|
||||
contact.put("imapUid", response.get("Name"));
|
||||
for (Map.Entry<String, String> entry : GALFIND_ATTRIBUTE_MAP.entrySet()) {
|
||||
String attributeValue = response.get(entry.getValue());
|
||||
if (attributeValue != null) {
|
||||
|
@ -27,7 +27,6 @@ import davmail.Settings;
|
||||
import davmail.exception.DavMailException;
|
||||
import davmail.exchange.ExchangeSession;
|
||||
import davmail.exchange.ExchangeSessionFactory;
|
||||
import davmail.imap.ImapConnection;
|
||||
import davmail.ui.tray.DavGatewayTray;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -208,14 +207,14 @@ public class LdapConnection extends AbstractConnection {
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("nsaimid", "im");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("nscpaimscreenname", "im");
|
||||
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("xmozillasecondemail", "email2");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("xmozillasecondemail", "smtpemail2");
|
||||
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("notes", "description");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("pagerphone", "pager");
|
||||
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("locality", "l");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("homephone", "homePhone");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillasecondemail", "email2");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillasecondemail", "smtpemail2");
|
||||
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("zip", "postalcode");
|
||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillahomestate", "homeState");
|
||||
|
@ -22,6 +22,7 @@ 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;
|
||||
@ -130,4 +131,11 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
|
||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(postalcode=N18 1ZF)", searchControls);
|
||||
}
|
||||
|
||||
public void testSearchByCnReturnSn() throws NamingException {
|
||||
SearchControls searchControls = new SearchControls();
|
||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||
searchControls.setReturningAttributes(new String[]{"sn"});
|
||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(cn=*)", searchControls);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user