Basic Directory Search Technology Sample
This sample shows how to search for objects in Active Directory that belong to a specific object class and how to return the list of results in ascending alphabetical order.
Note |
---|
This sample uses fictitious values and cannot be run until it is modified with real values. |
For information about using the samples, see the following topics:
To customize the sample for your settings
Modify the following string variables with real values in the BasicDirectorySearch.cs or BasicDirectorySearch.vb file, depending on which version of the sample is being built:
domainADsPath - LDAP path to domain
username - user name for authentication to Active Directory
password - password for authentication to Active Directory
schemaClassNameToSearch - schema class name for which to print out information
To build the sample
At a command prompt, navigate to the Technologies\DirectoryServices\BasicDirectorySearch directory. Navigate to the CS or VB directory, depending on which version of the sample is being built. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.
Type msbuild basicdirectorysearch.sln at the command line.
To run the sample
At a command prompt, navigate to the directory that contains the built executable file.
Type basicdirectorysearch and press Enter.
Note |
---|
This sample is a console application. You must start and run at a command prompt window to view its output. |
Remarks
This sample lists the following information:
Total number of results found
Total number of properties found
The name of each property
The Active Directory path, displayName property and name property for each search result
This sample demonstrates the following tasks:
How to instantiate an Active Directory DirectorySearcher object
How to instantiate a DirectoryEntry object, authenticating to Active Directory by providing a username and password
How to specify Active Directory search parameters such as Filter, PageSize, PropertiesLoad and SearchScope on a DirectorySearcher object
How to search Active Directory using the FindAll method of the DirectorySearcher object
How to access the results of an Active Directory search using the SearchResultCollection object