Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DirectoryContext Class

The DirectoryContext class identifies a specific directory and the credentials that are used to access the directory.

Namespace: System.DirectoryServices.ActiveDirectory
Assembly: System.DirectoryServices (in system.directoryservices.dll)

public class DirectoryContext
public class DirectoryContext
public class DirectoryContext
Not applicable.

A directory context must be created before accessing the methods and properties of a System.DirectoryServices.ActiveDirectory directory object such as a domain or forest.

When creating a directory context, the process' current credentials or alternate credentials can be applied to that context by using the appropriate constructor. These credentials determine the permissions that are in effect when the program accesses directory objects. Because Active Directory Domain Services objects might be protected against retrieval or modification by non-administrative users, the use of alternate credentials with permission to access the target objects is sometimes necessary for proper program functionality.

The following table contains a list of the target types that are allowed and a description of the format of the target string.

Target type

DirectoryContextType member

Target name format

Domain Controller

DirectoryServer

The DNS name of the domain controller.

AD LDS Instance

DirectoryServer

The DNS name of the AD LDS server and the LDAP port number, for example, ad_lds_instance.fabrikam.com:389.

Domain

Domain

The DNS name of the domain, for example, sales.corp.fabrikam.com.

Forest

Forest

The DNS name of the forest, for example, corp.fabrikam.com.

Application Partition

ApplicationPartition

The DNS name of the application partition.

AD LDS Configuration Set

ConfigurationSet

One of the keywords that is associated with the service connection point registered by AD LDS instances for the configuration set.

System.Object
  System.DirectoryServices.ActiveDirectory.DirectoryContext

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft