ValidateCredentials Method (String, String, ContextOptions)
Collapse the table of content
Expand the table of content

PrincipalContext.ValidateCredentials Method (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.

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

public bool ValidateCredentials(
	string userName,
	string password,
	ContextOptions options
)

Parameters

userName
Type: System.String

The username that is validated on the server.

password
Type: System.String

The password that is validated on the server.

options
Type: System.DirectoryServices.AccountManagement.ContextOptions

A combination of one or more ContextOptions enumeration values the options used to bind to the server. This parameter can only specify Simple bind with or without SSL, or Negotiate bind.

Return Value

Type: System.Boolean

true if the credentials are valid; otherwise false.

Exception Condition
ArgumentException

The options parameter must specify Negotiate when the context type is T:System.DirectoryServices.AccountManagement.ContextType.Machine.

The ValidateCredentials method binds to the server specified in the constructor. If the username and password parameters are null, the credentials specified in the constructor are validated. If no credential were specified in the constructor, and the username and password parameters are null, this method validates the default credentials for the current principal.

.NET Framework
Available since 3.5
Return to top
Show:
© 2016 Microsoft