Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DirectoryContext Class

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

System.Object
  System.DirectoryServices.ActiveDirectory.DirectoryContext

Namespace:  System.DirectoryServices.ActiveDirectory
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)
public class DirectoryContext

The DirectoryContext type exposes the following members.

  NameDescription
Public methodDirectoryContext(DirectoryContextType)Initializes a new instance of the DirectoryContext class of the specified type that contains the credentials of the current user context.
Public methodDirectoryContext(DirectoryContextType, String)Initializes a new instance of the DirectoryContext class of the specified type that contains the specified name and the credentials of the current user context.
Public methodDirectoryContext(DirectoryContextType, String, String)Initializes a new instance of the DirectoryContext class of the specified type that contains the specified user name and password.
Public methodDirectoryContext(DirectoryContextType, String, String, String)Initializes a new instance of the DirectoryContext class of the specified type that contains the specified target, user name, and password.
Top
  NameDescription
Public propertyContextTypeGets the type of the context object.
Public propertyNameGets the name of the context.
Public propertyUserNameGets the user name of the context.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft. All rights reserved.