Export (0) Print
Expand All

PrincipalContext Class

Encapsulates the server or domain against which all operations are performed, the container that is used as the base of those operations, and the credentials used to perform the operations.

System::Object
  System.DirectoryServices.AccountManagement::PrincipalContext

Namespace:  System.DirectoryServices.AccountManagement
Assembly:  System.DirectoryServices.AccountManagement (in System.DirectoryServices.AccountManagement.dll)

[SecurityPermissionAttribute(SecurityAction::Assert, Flags = SecurityPermissionFlag::UnmanagedCode)]
[DirectoryServicesPermissionAttribute(SecurityAction::InheritanceDemand, Unrestricted = true)]
[DirectoryServicesPermissionAttribute(SecurityAction::LinkDemand, Unrestricted = true)]
public ref class PrincipalContext : IDisposable

The PrincipalContext type exposes the following members.

  NameDescription
Public methodPrincipalContext(ContextType)Initializes a new instance of the PrincipalContext class with the specified context type.
Public methodPrincipalContext(ContextType, String)Initializes a new instance of the PrincipalContext class with the specified context type and name.
Public methodPrincipalContext(ContextType, String, String)Initializes a new instance of the PrincipalContext class with the specified context type, name, and container.
Public methodPrincipalContext(ContextType, String, String, ContextOptions)Initializes a new instance of the PrincipalContext class with the specified context type, name, container, and context options.
Public methodPrincipalContext(ContextType, String, String, String)Initializes a new instance of the PrincipalContext class with the specified context type, name, username, and password.
Public methodPrincipalContext(ContextType, String, String, String, String)Initializes a new instance of the PrincipalContext class with the specified context type, name, container, username, and password.
Public methodPrincipalContext(ContextType, String, String, ContextOptions, String, String)Initializes a new instance of the PrincipalContext class with the specified context type, name, container, context options, username, and password.
Top

  NameDescription
Public propertyConnectedServerGets the name of the server to which the principal context is connected.
Public propertyContainerGets the value specified in the container parameter in the constructor.
Public propertyContextTypeGets the context type that specifies the type of store for the principal context.
Public propertyNameGets the value specified as the name parameter in the constructor.
Public propertyOptionsGets the options specified in the contextOptions parameter of the constructor.
Public propertyUserNameGets the value specified in the username parameter in the constructor.
Top

  NameDescription
Public methodDisposeDisposes the current instance of the PrincipalContext object.
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.)
Public methodValidateCredentials(String, String)Creates the connections to the server and returns a Boolean value that specifies whether the specified username and password are valid.
Public methodValidateCredentials(String, String, ContextOptions)Creates the connections to the server and returns a Boolean value that specifies whether the specified user name and password are valid. This method performs fast credential validation of the username and password.
Top

For search operations, the principal context defines the search base, and for insert operations the context defines the container into which the object is inserted.

.NET Framework

Supported in: 4.6, 4, 3.5

.NET Framework Client Profile

Supported in: 4

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