mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-12 22:18:11 -05:00
LDAP: fix 3166460, do not fail on NOT (0xa2) filter
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1620 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b130d1a5f2
commit
15610e4f0d
@ -310,6 +310,7 @@ public class LdapConnection extends AbstractConnection {
|
||||
// LDAP filter code
|
||||
static final int LDAP_FILTER_AND = 0xa0;
|
||||
static final int LDAP_FILTER_OR = 0xa1;
|
||||
static final int LDAP_FILTER_NOT = 0xa2;
|
||||
|
||||
// LDAP filter operators
|
||||
static final int LDAP_FILTER_SUBSTRINGS = 0xa4;
|
||||
@ -604,7 +605,8 @@ public class LdapConnection extends AbstractConnection {
|
||||
protected LdapFilter parseNestedFilter(BerDecoder reqBer, int ldapFilterType, int end) throws IOException {
|
||||
LdapFilter nestedFilter;
|
||||
|
||||
if ((ldapFilterType == LDAP_FILTER_OR) || (ldapFilterType == LDAP_FILTER_AND)) {
|
||||
if ((ldapFilterType == LDAP_FILTER_OR) || (ldapFilterType == LDAP_FILTER_AND)
|
||||
|| ldapFilterType == LDAP_FILTER_NOT) {
|
||||
nestedFilter = new CompoundFilter(ldapFilterType);
|
||||
|
||||
while (reqBer.getParsePosition() < end && reqBer.bytesLeft() > 0) {
|
||||
@ -915,8 +917,10 @@ public class LdapConnection extends AbstractConnection {
|
||||
|
||||
if (type == LDAP_FILTER_OR) {
|
||||
buffer.append("(|");
|
||||
} else {
|
||||
} else if (type == LDAP_FILTER_AND) {
|
||||
buffer.append("(&");
|
||||
} else {
|
||||
buffer.append("(!");
|
||||
}
|
||||
|
||||
for (LdapFilter child : criteria) {
|
||||
|
@ -36,6 +36,7 @@ import java.util.Hashtable;
|
||||
/**
|
||||
* Test LDAP.
|
||||
*/
|
||||
@SuppressWarnings({"JavaDoc"})
|
||||
public class TestLdap extends AbstractExchangeSessionTestCase {
|
||||
InitialLdapContext ldapContext;
|
||||
|
||||
@ -152,4 +153,19 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
|
||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(|(mail=Test*)(cn=Test*)(givenname=Test*)(sn=Test*))", searchControls);
|
||||
}
|
||||
|
||||
public void testThunderbird() throws NamingException {
|
||||
String filter = "(|(sn=*stocker*)(givenname=*stocker*)(mail=*stocker*)(cn=*stocker*))";
|
||||
String[] returningAttributes = new String[]{"custom1", "mozillausehtmlmail", "postalcode", "custom2", "custom3", "custom4", "street", "surname", "telephonenumber", "mozillahomelocalityname", "orgunit", "mozillaworkstreet2", "xmozillanickname", "mozillahomestreet", "description", "cellphone", "homeurl", "mozillahomepostalcode", "departmentnumber", "postofficebox", "st", "objectclass", "sn", "ou", "fax", "mozillahomeurl", "mozillahomecountryname", "streetaddress", "cn", "company", "mozillaworkurl", "mobile", "region", "birthmonth", "birthday", "labeleduri", "carphone", "department", "xmozillausehtmlmail", "givenname", "nsaimid", "workurl", "facsimiletelephonenumber", "mozillanickname", "title", "nscpaimscreenname", "xmozillasecondemail", "mozillacustom3", "countryname", "mozillacustom4", "mozillacustom1", "mozillacustom2", "homephone", "mozillasecondemail", "pager", "zip", "mail", "c", "mozillahomestate", "o", "l", "birthyear", "modifytimestamp", "locality", "commonname", "notes", "pagerphone", "mozillahomestreet2"};
|
||||
SearchControls searchControls = new SearchControls();
|
||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||
searchControls.setReturningAttributes(returningAttributes);
|
||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", filter, searchControls);
|
||||
}
|
||||
|
||||
public void testSearchNotFilter() throws NamingException {
|
||||
SearchControls searchControls = new SearchControls();
|
||||
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
|
||||
searchControls.setReturningAttributes(new String[]{"mail"});
|
||||
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(!(objectclass=test))", searchControls);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user