Export (0) Print
Expand All

PrincipalContext Constructor

Initializes a new instance of the PrincipalContext class.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method PrincipalContext(ContextType) Initializes a new instance of the PrincipalContext class with the specified context type.
Public method PrincipalContext(ContextType, String) Initializes a new instance of the PrincipalContext class with the specified context type and name.
Public method PrincipalContext(ContextType, String, String) Initializes a new instance of the PrincipalContext class with the specified context type, name, and container.
Public method PrincipalContext(ContextType, String, String, ContextOptions) Initializes a new instance of the PrincipalContext class with the specified context type, name, container, and context options.
Public method PrincipalContext(ContextType, String, String, String) Initializes a new instance of the PrincipalContext class with the specified context type, name, username, and password.
Public method PrincipalContext(ContextType, String, String, String, String) Initializes a new instance of the PrincipalContext class with the specified context type, name, container, username, and password.
Public method PrincipalContext(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

The PrincipalContext constructors perform validation of the parameters and server, but not do not attempt to validate credentials.

When the principal context object is created without specifying a container, it may be used to represent multiple distinct containers. One container may be used as the base of query operations, while additional containers can hold newly-created principal objects. For example, when users or groups are inserted into the domian context type, the Account Management API uses the default well-known user container, "CN=Users,DC=Fabrikam,DC=com". When computers are inserted in the store, the API uses the default "CN=Computers,DC=Fabrikam,DC=com" container. Note that the default container names can be changed by the domain administrator. Since the principal object constructors can only specify one principal context, additional contexts are exposed as the default behavior when the application creates a domain context without specifying a container. Since the application directory does not have well-known containers, the application must specify a container in the constructor or the ArgumentException is thrown. Since SAM does not have containers, a ArgumentException is thrown if the application attempts to specify a container in the constructor.

In each version of the constructor that takes a user name as a parameter, the userName string can be in various different formats. The three supported NameFormats for are Nt4Name, UserPrincipalName, and SamAccountName. For more information about name formats, see the ADS_NAME_TYPE_ENUM documentation here.

Show:
© 2014 Microsoft