LDAP Client.Net

Client.Search Method (String, String)

Search the directory. Searches the subtree. Retrieves all attributes. Has no timeout. Does not ignore the size limit error. For a complete description of search syntax, see RFC 1558: A String Representation of LDAP Search Filters (http://www.faqs.org/rfcs/rfc1558.html).

[Visual Basic]
Public Function Search( _ 
   ByVal base As String, _ 
   ByVal filter As String _ 
) As EntryCollection
[C#]
public EntryCollection Search(
   string base,
   string filter
);
[C++]
public: EntryCollection* Search(
   String* base,
   String* filter
);
[JScript]
public function Search(
   String base,
   String filter
): EntryCollection;

Parameters

base
Base DN.
filter
Search filter.

Return Value

Collection of entries matching the search query.

Example

[C#]
using System;
using LdapServices.Ldap;

namespace LDAPSampleCodeConsole
{
class SampleApp
{
static void Main(string[] args)
{
Client client = new Client();

// Connect to the directory
client.Connect("directory.yourCompany.ca");

// Search the directory for entries with surname starting with 'Ab'
EntryCollection entries;
entries = client.Search("o=yourCompany,c=ca", "sn=Ab*");

Console.WriteLine("Count: " + entries.Count);

// Disconnect
client.Disconnect();
}
}
}

See Also

Client Class | LdapServices.Ldap Namespace | Client.Search Overload List