search Method

Searches the directory server using the base object specified in DN and the search filter SearchFilter .

Syntax

def search(search_filter: str) -> None: ...

Remarks

This method searches the directory server using the base object specified in the dn and the search filter specified in the SearchFilter parameter. Additional search parameters are specified through the search_scope, search_deref_aliases, search_size_limit, search_time_limit, and search_return_values properties.

If attributes are specified before starting a search, the server will only return results that contain a value for the specified attributes.

Results are returned through zero or more on_search_result events, after which a on_search_complete event is fired.

Example (Searching for a User)


LDAPControl.DN = "ou=Employees,dc=server"
LDAPControl.Search("uid=TThompson")

A DSE Search (Directory Specific Entries) will search for attributes of the server itself. Example (DSE Search)


LDAPControl.DN = "" 
LDAPControl.SearchScope = 0
LDAPControl.Search("objectClass=*")

SearchFilter is a string representation of the LDAP search filter used for the search.

The format of the search filter is specified by RFC 1558 and is identical to the format used by most LDAP applications.

The following are examples of search filters, as provided in the RFC:


     (cn=Babs Jensen)
     (!(cn=Tim Howes))
     (&(objectClass=Person)(|(sn=Jensen)(cn=Babs J*)))
     (o=univ*of*mich*)

The complete specification is given by the following BNF:


     <filter> ::= "(" <filtercomp> ")"
     <filtercomp> ::= <and> | <or> | <not> | <item>
     <and> ::= "&" <filterlist>
     <or> ::= "|" <filterlist>
     <not> ::= "!" <filter>
     <filterlist> ::= <filter> | <filter> <filterlist>
     <item> ::= <simple> | <present> | <substring>
     <simple> ::= <attr> <filtertype> <value>
     <filtertype> ::= <equal> | <approx> | <greater> | <less>
     <equal> ::= "="
     <approx> ::= "~="
     <greater> ::= ">="
     <less> ::= "<="
     <present> ::= <attr> "=*"
     <substring> ::= <attr> "=" <initial> <any> <final>
     <initial> ::= NULL | <value>
     <any> ::= "*" <starval>
     <starval> ::= NULL | <value> "*" <starval>
     <final> ::= NULL | <value>

<attr> is a string representing an attribute type as defined in RFC 1777. <value> is a string representing an attribute value, or part of one, and has the form defined in RFC 1779. If a <value> must contain one of the characters '*' or '(' or ')', these should be escaped by preceding them with the backslash '\' character.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks 2020 Python Edition - Version 20.0 [Build 8307]