@@ -251,6 +251,8 @@ async def bind(self):
251251 :return: A tuple of (True, None) on success or (False, Exception) on error.
252252 :rtype: (:class:`bool`, :class:`Exception`)
253253 """
254+ if self .status != MSLDAPClientStatus .CONNECTED :
255+ raise Exception ("Connect to the LDAP server before binding." )
254256 logger .debug ('BIND in progress...' )
255257 try :
256258 if self .credential .protocol == asyauthProtocol .SICILY :
@@ -647,7 +649,7 @@ async def delete(self, entry:str):
647649 except Exception as e :
648650 return False , e
649651
650- async def search (self , base :str , query :str , attributes :List [str ], search_scope :int = 2 , size_limit :int = 1000 , types_only :bool = False , derefAliases :int = 0 , timeLimit :int = None , controls :List [Control ] = None , return_done :bool = False ):
652+ async def search (self , base :str , query :str , attributes :List [bytes ], search_scope :int = 2 , size_limit :int = 1000 , types_only :bool = False , derefAliases :int = 0 , timeLimit :int = None , controls :List [Control ] = None , return_done :bool = False ):
651653 """
652654 Performs the search operation.
653655
@@ -656,7 +658,7 @@ async def search(self, base:str, query:str, attributes:List[str], search_scope:i
656658 :param query: filter query that defines what should be searched for
657659 :type query: str
658660 :param attributes: a list of attributes to be included in the response
659- :type attributes: List[str ]
661+ :type attributes: List[bytes ]
660662 :param search_scope: Specifies the search operation's scope. Default: 2 (Subtree)
661663 :type search_scope: int
662664 :param types_only: indicates whether the entries returned should include attribute types only or both types and values. Default: False (both)
@@ -675,7 +677,10 @@ async def search(self, base:str, query:str, attributes:List[str], search_scope:i
675677 :return: Async generator which yields (`LDAPMessage`, None) tuple on success or (None, `Exception`) on error
676678 :rtype: Iterator[(:class:`LDAPMessage`, :class:`Exception`)]
677679 """
678- if self .status not in [MSLDAPClientStatus .CONNECTED , MSLDAPClientStatus .RUNNING ]:
680+ if self .status == MSLDAPClientStatus .CONNECTED :
681+ yield None , Exception ('Connected, but not bound.' )
682+ return
683+ if self .status != MSLDAPClientStatus .RUNNING :
679684 yield None , Exception ('Connection not running! Probably encountered an error' )
680685 return
681686 try :
@@ -728,7 +733,7 @@ async def search(self, base:str, query:str, attributes:List[str], search_scope:i
728733 except Exception as e :
729734 yield (None , e )
730735
731- async def pagedsearch (self , base :str , query :str , attributes :List [str ], search_scope :int = 2 , size_limit :int = 1000 , typesOnly :bool = False , derefAliases :bool = 0 , timeLimit :int = None , controls :List [Control ] = None , rate_limit :int = 0 ):
736+ async def pagedsearch (self , base :str , query :str , attributes :List [bytes ], search_scope :int = 2 , size_limit :int = 1000 , typesOnly :bool = False , derefAliases :bool = 0 , timeLimit :int = None , controls :List [Control ] = None , rate_limit :int = 0 ):
732737 """
733738 Paged search is the same as the search operation and uses it under the hood. Adds automatic control to read all results in a paged manner.
734739
@@ -737,7 +742,7 @@ async def pagedsearch(self, base:str, query:str, attributes:List[str], search_sc
737742 :param query: filter query that defines what should be searched for
738743 :type query: str
739744 :param attributes: a list of attributes to be included in the response
740- :type attributes: List[str ]
745+ :type attributes: List[bytes ]
741746 :param search_scope: Specifies the search operation's scope. Default: 2 (Subtree)
742747 :type search_scope: int
743748 :param types_only: indicates whether the entries returned should include attribute types only or both types and values. Default: False (both)
@@ -756,6 +761,9 @@ async def pagedsearch(self, base:str, query:str, attributes:List[str], search_sc
756761 :rtype: Iterator[(:class:`dict`, :class:`Exception`)]
757762 """
758763
764+ if self .status == MSLDAPClientStatus .CONNECTED :
765+ yield None , Exception ('Connected, but not bound.' )
766+ return
759767 if self .status != MSLDAPClientStatus .RUNNING :
760768 yield None , Exception ('Connection not running! Probably encountered an error' )
761769 return
0 commit comments