Udostępnij za pośrednictwem


Directory Synchronization Search Technology Sample

This sample shows how directory synchronization search works in System.DirectoryServices.

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 DirSyncSearch.cs or DirSyncSearch.vb file, depending on which version of the sample is being built:

    • domainADsPath - LDAP path to domain

To build the sample

  1. At a command prompt, navigate to the \DS\DirSyncSearch 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.

  2. At a command prompt, type msbuild dirsyncsearch.sln.

To run the sample

  1. Ata command prompt, navigate to the directory that contains the built executable file.

  2. Type dirsyncsearch and press Enter.

Note

This sample is a console application. You must start and run it at a command prompt to view its output.

Remarks

This sample lists the following information:

  • Results of a directory search for all user names, after adding a temporary user to Active Directory

  • Results of a synchronized directory search for all user names that continues the directory search that was performed in the previous step, showing that no new search results are available

  • Results of a synchronized directory search for all user names that continues the directory search performed in the prior step, after the user name of the temporary user has been modified, showing that the changed user-name property appears in the search

This sample demonstrates the following tasks:

  • How to add and remove a temporary user in Active Directory

  • How to create a DirectoryEntry object for the specified path

  • How to perform a directory search across all user objects, returning each user object's displayName and name properties, by using a DirectorySearcher object

  • How to set search options using various properties of the DirectorySearcher object

  • How to use a DirectorySynchronization object in combination with a DirectorySearcher object to create a search that can keep track of its current results so that future executions of the same search report only new results that satisfy the specified criteria