3

While accessing LDAP data , I am continuously receiving the Size Limit Exceeded error.

One of the solutions presented on google asked for much tighter search Filters.

How is it possible to combine two or more search filters in python LDAP ? Using the suggested (|(filter1)(filter2)) is producing an error.

Here is the query :

baseDn = "ou=active, ou=employees, ou=people, o=xxxxx.com";
searchScope = ldap.SCOPE_SUBTREE
#retrieve Certain attributes
retrieveAttributes = ["manageruid","manager","cn"]
search_query = raw_input("Enter the query :")
#This searchFilter needs to be more specific
searchFilter = "city=" + "Bangalore"

try :
   ldap_result_id = l.search(baseDn, searchScope, searchFilter,   retrieveAttributes)
   result_set = []
   while 1:
       result_type, result_data = l.result(ldap_result_id, 0)
       if(result_data == []):
           break
       else:
           if result_type == ldap.RES_SEARCH_ENTRY:
               result_set.append(result_data)
       #print result_set
       print len(result_set)   

except ldap.LDAPError, e:
    print e

While trying to combine search filters : This error comes.

 File "practice.py", line 33
    search_filter = (&("city=Bangalore")("manageruid=278586"))
                     ^
SyntaxError: invalid syntax 
4

1 回答 1

8

我认为search_filter必须是一个字符串。你试过这个吗?

search_filter = "(&(city=Bangalore)(manageruid=278586))"
于 2014-02-27T06:41:00.567 回答