mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32: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 {
|
protected static class AutoDiscoverMethod extends PostMethod {
|
||||||
AutoDiscoverMethod(String autodiscoverHost, String userEmail) {
|
AutoDiscoverMethod(String autodiscoverHost, String userEmail) {
|
||||||
super("https://"+autodiscoverHost+"/autodiscover/autodiscover.xml");
|
super("https://" + autodiscoverHost + "/autodiscover/autodiscover.xml");
|
||||||
setAutoDiscoverRequestEntity(userEmail);
|
setAutoDiscoverRequestEntity(userEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,6 +529,16 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
// encode urlcompname
|
// encode urlcompname
|
||||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
||||||
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
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 {
|
} else {
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
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>();
|
protected static final HashMap<String, String> GALFIND_ATTRIBUTE_MAP = new HashMap<String, String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
GALFIND_ATTRIBUTE_MAP.put("uid", "Name");
|
GALFIND_ATTRIBUTE_MAP.put("imapUid", "Name");
|
||||||
GALFIND_ATTRIBUTE_MAP.put("cn", "DisplayName");
|
GALFIND_ATTRIBUTE_MAP.put("cn", "DisplayName");
|
||||||
GALFIND_ATTRIBUTE_MAP.put("givenName", "GivenName");
|
GALFIND_ATTRIBUTE_MAP.put("givenName", "GivenName");
|
||||||
GALFIND_ATTRIBUTE_MAP.put("sn", "Surname");
|
GALFIND_ATTRIBUTE_MAP.put("sn", "Surname");
|
||||||
@ -1499,7 +1509,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
protected Contact buildGalfindContact(EWSMethod.Item response) {
|
protected Contact buildGalfindContact(EWSMethod.Item response) {
|
||||||
Contact contact = new Contact();
|
Contact contact = new Contact();
|
||||||
contact.setName(response.get("Name"));
|
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()) {
|
for (Map.Entry<String, String> entry : GALFIND_ATTRIBUTE_MAP.entrySet()) {
|
||||||
String attributeValue = response.get(entry.getValue());
|
String attributeValue = response.get(entry.getValue());
|
||||||
if (attributeValue != null) {
|
if (attributeValue != null) {
|
||||||
|
@ -27,7 +27,6 @@ import davmail.Settings;
|
|||||||
import davmail.exception.DavMailException;
|
import davmail.exception.DavMailException;
|
||||||
import davmail.exchange.ExchangeSession;
|
import davmail.exchange.ExchangeSession;
|
||||||
import davmail.exchange.ExchangeSessionFactory;
|
import davmail.exchange.ExchangeSessionFactory;
|
||||||
import davmail.imap.ImapConnection;
|
|
||||||
import davmail.ui.tray.DavGatewayTray;
|
import davmail.ui.tray.DavGatewayTray;
|
||||||
import org.apache.log4j.Logger;
|
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("nsaimid", "im");
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("nscpaimscreenname", "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("notes", "description");
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("pagerphone", "pager");
|
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("pagerphone", "pager");
|
||||||
|
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("locality", "l");
|
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("locality", "l");
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("homephone", "homePhone");
|
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("zip", "postalcode");
|
||||||
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillahomestate", "homeState");
|
LDAP_TO_CONTACT_ATTRIBUTE_MAP.put("mozillahomestate", "homeState");
|
||||||
|
@ -22,6 +22,7 @@ import davmail.DavGateway;
|
|||||||
import davmail.Settings;
|
import davmail.Settings;
|
||||||
import davmail.exchange.AbstractExchangeSessionTestCase;
|
import davmail.exchange.AbstractExchangeSessionTestCase;
|
||||||
import davmail.exchange.ExchangeSessionFactory;
|
import davmail.exchange.ExchangeSessionFactory;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
|
||||||
import javax.naming.NamingEnumeration;
|
import javax.naming.NamingEnumeration;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
@ -130,4 +131,11 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
|
|||||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(postalcode=N18 1ZF)", searchControls);
|
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