Rediger

Del via


PrincipalContext.ValidateCredentials Method

Definition

Creates the connection to the server and validates the specified credentials if the connection is successful.

Overloads

ValidateCredentials(String, String)

Creates the connections to the server and returns a Boolean value that specifies whether the specified username and password are valid.

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

Remarks

The userName argument in both overloads of this method must take the form username (for example, mcampbell) rather than domain\username or username@domain.

ValidateCredentials(String, String)

Source:
Context.cs
Source:
Context.cs
Source:
Context.cs
Source:
Context.cs
Source:
Context.cs

Creates the connections to the server and returns a Boolean value that specifies whether the specified username and password are valid.

public:
 bool ValidateCredentials(System::String ^ userName, System::String ^ password);
public bool ValidateCredentials (string userName, string password);
member this.ValidateCredentials : string * string -> bool
Public Function ValidateCredentials (userName As String, password As String) As Boolean

Parameters

userName
String

The username that is validated on the server. See the Remarks section for more information on the format of userName.

password
String

The password that is validated on the server.

Returns

true if the credentials are valid; otherwise false.

Remarks

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

The userName argument must take the form userName (for example, mcampbell) rather than domain\username or username@domain.

Applies to

ValidateCredentials(String, String, ContextOptions)

Source:
Context.cs
Source:
Context.cs
Source:
Context.cs
Source:
Context.cs
Source:
Context.cs

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.

public:
 bool ValidateCredentials(System::String ^ userName, System::String ^ password, System::DirectoryServices::AccountManagement::ContextOptions options);
public bool ValidateCredentials (string userName, string password, System.DirectoryServices.AccountManagement.ContextOptions options);
member this.ValidateCredentials : string * string * System.DirectoryServices.AccountManagement.ContextOptions -> bool
Public Function ValidateCredentials (userName As String, password As String, options As ContextOptions) As Boolean

Parameters

userName
String

The username that is validated on the server. See the Remarks section for information on the format of userName.

password
String

The password that is validated on the server.

options
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.

Returns

true if the credentials are valid; otherwise false.

Exceptions

The options parameter must specify Negotiate when the context type is Machine.

Remarks

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

The userName argument must take the form username (for example, mcampbell) rather than domain\username or username@domain.

Applies to