Search Method
Searches the directory server using the base object specified in DN and the search filter SearchFilter .
Syntax
[VB.NET] Public Sub Search(ByVal SearchFilter As String)
[C#] public void Search(string searchFilter);
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 SearchScope, SearchDerefAliases, SearchSizeLimit, SearchTimeLimit, and SearchReturnValues 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 SearchResult events, after which a SearchComplete 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.
NOTE: This method has a corresponding asynchronous version (SearchAsync) for use in the WinRT environment.