@@ -748,7 +748,7 @@ def result4(self,msgid=ldap.RES_ANY,all=1,timeout=None,add_ctrls=0,add_intermedi
748
748
resp_data = self ._bytesify_results (resp_data , with_ctrls = add_ctrls )
749
749
return resp_type , resp_data , resp_msgid , decoded_resp_ctrls , resp_name , resp_value
750
750
751
- def search_ext (self ,base ,scope ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ,sizelimit = 0 ):
751
+ def search_ext (self ,base ,scope ,filterstr = None ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ,sizelimit = 0 ):
752
752
"""
753
753
search(base, scope [,filterstr='(objectClass=*)' [,attrlist=None [,attrsonly=0]]]) -> int
754
754
search_s(base, scope [,filterstr='(objectClass=*)' [,attrlist=None [,attrsonly=0]]])
@@ -793,17 +793,24 @@ def search_ext(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrson
793
793
The amount of search results retrieved can be limited with the
794
794
sizelimit parameter if non-zero.
795
795
"""
796
+
796
797
if PY2 :
797
798
base = self ._bytesify_input ('base' , base )
798
- # workaround for default argument,
799
- # see https://github.com/python-ldap/python-ldap/issues/147
800
- if self .bytes_mode and filterstr == '(objectClass=*)' :
801
- filterstr = b'(objectClass=*)'
799
+ if filterstr is None :
800
+ # workaround for default argument,
801
+ # see https://github.com/python-ldap/python-ldap/issues/147
802
+ if self .bytes_mode :
803
+ filterstr = b'(objectClass=*)'
804
+ else :
805
+ filterstr = u'(objectClass=*)'
802
806
else :
803
807
filterstr = self ._bytesify_input ('filterstr' , filterstr )
804
808
if attrlist is not None :
805
809
attrlist = tuple (self ._bytesify_input ('attrlist' , a )
806
810
for a in attrlist )
811
+ else :
812
+ if filterstr is None :
813
+ filterstr = '(objectClass=*)'
807
814
return self ._ldap_call (
808
815
self ._l .search_ext ,
809
816
base ,scope ,filterstr ,
@@ -813,17 +820,17 @@ def search_ext(self,base,scope,filterstr='(objectClass=*)',attrlist=None,attrson
813
820
timeout ,sizelimit ,
814
821
)
815
822
816
- def search_ext_s (self ,base ,scope ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ,sizelimit = 0 ):
823
+ def search_ext_s (self ,base ,scope ,filterstr = None ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ,sizelimit = 0 ):
817
824
msgid = self .search_ext (base ,scope ,filterstr ,attrlist ,attrsonly ,serverctrls ,clientctrls ,timeout ,sizelimit )
818
825
return self .result (msgid ,all = 1 ,timeout = timeout )[1 ]
819
826
820
- def search (self ,base ,scope ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ):
827
+ def search (self ,base ,scope ,filterstr = None ,attrlist = None ,attrsonly = 0 ):
821
828
return self .search_ext (base ,scope ,filterstr ,attrlist ,attrsonly ,None ,None )
822
829
823
- def search_s (self ,base ,scope ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ):
830
+ def search_s (self ,base ,scope ,filterstr = None ,attrlist = None ,attrsonly = 0 ):
824
831
return self .search_ext_s (base ,scope ,filterstr ,attrlist ,attrsonly ,None ,None ,timeout = self .timeout )
825
832
826
- def search_st (self ,base ,scope ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ,timeout = - 1 ):
833
+ def search_st (self ,base ,scope ,filterstr = None ,attrlist = None ,attrsonly = 0 ,timeout = - 1 ):
827
834
return self .search_ext_s (base ,scope ,filterstr ,attrlist ,attrsonly ,None ,None ,timeout )
828
835
829
836
def start_tls_s (self ):
@@ -910,7 +917,7 @@ def search_subschemasubentry_s(self,dn=None):
910
917
dn = empty_dn
911
918
try :
912
919
r = self .search_s (
913
- dn ,ldap .SCOPE_BASE ,'(objectClass=*)' ,[attrname ]
920
+ dn ,ldap .SCOPE_BASE ,None ,[attrname ]
914
921
)
915
922
except (ldap .NO_SUCH_OBJECT ,ldap .NO_SUCH_ATTRIBUTE ,ldap .INSUFFICIENT_ACCESS ):
916
923
r = []
@@ -943,7 +950,7 @@ def read_s(self,dn,filterstr=None,attrlist=None,serverctrls=None,clientctrls=Non
943
950
r = self .search_ext_s (
944
951
dn ,
945
952
ldap .SCOPE_BASE ,
946
- filterstr or '(objectClass=*)' ,
953
+ filterstr ,
947
954
attrlist = attrlist ,
948
955
serverctrls = serverctrls ,
949
956
clientctrls = clientctrls ,
@@ -977,7 +984,7 @@ def read_subschemasubentry_s(self,subschemasubentry_dn,attrs=None):
977
984
else :
978
985
return subschemasubentry
979
986
980
- def find_unique_entry (self ,base ,scope = ldap .SCOPE_SUBTREE ,filterstr = '(objectClass=*)' ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ):
987
+ def find_unique_entry (self ,base ,scope = ldap .SCOPE_SUBTREE ,filterstr = None ,attrlist = None ,attrsonly = 0 ,serverctrls = None ,clientctrls = None ,timeout = - 1 ):
981
988
"""
982
989
Returns a unique entry, raises exception if not unique
983
990
"""
@@ -996,7 +1003,7 @@ def find_unique_entry(self,base,scope=ldap.SCOPE_SUBTREE,filterstr='(objectClass
996
1003
raise NO_UNIQUE_ENTRY ('No or non-unique search result for %s' % (repr (filterstr )))
997
1004
return r [0 ]
998
1005
999
- def read_rootdse_s (self , filterstr = '(objectClass=*)' , attrlist = None ):
1006
+ def read_rootdse_s (self , filterstr = None , attrlist = None ):
1000
1007
"""
1001
1008
convenience wrapper around read_s() for reading rootDSE
1002
1009
"""
0 commit comments