PrincipalContext.ValidateCredentials 方法

定义

创建到服务器的连接,如果连接成功,则验证指定的凭据。Creates the connection to the server and validates the specified credentials if the connection is successful.

重载

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.

注解

userName此方法的两个重载中的参数都必须采用用户名 (例如, mcampbell) 而不是域**用户名或*用户名 @ 域*。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)

创建到服务器的连接并返回一个布尔值,该值指定所指定的用户名和密码是否有效。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

参数

userName
String

在服务器上验证的用户名。The username that is validated on the server. 有关 userName 格式的详细信息,请参阅“备注”部分。See the Remarks section for more information on the format of userName.

password
String

在服务器上验证的密码。The password that is validated on the server.

返回

Boolean

如果凭据有效,则为 true;否则为 falsetrue if the credentials are valid; otherwise false.

注解

ValidateCredentials方法绑定到构造函数中指定的服务器。The ValidateCredentials method binds to the server specified in the constructor. 如果 usernamepassword 参数为 null ,则此方法将验证当前主体的默认凭据。If the username and password arguments are null, this method validates the default credentials for the current principal.

userName参数的格式必须为用户名 (例如mcampbell) ,而不是域**用户名或*用户名 @ 域*。The userName argument must take the form userName (for example, mcampbell) rather than domain\username or username@domain.

适用于

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.

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

参数

userName
String

在服务器上验证的用户名。The username that is validated on the server. 有关 userName 格式的信息,请参阅“备注”部分。See the Remarks section for information on the format of userName.

password
String

在服务器上验证的密码。The password that is validated on the server.

options
ContextOptions

一个或多个 ContextOptions 枚举值的组合,这些枚举值指定用于绑定到服务器的选项。A combination of one or more ContextOptions enumeration values the options used to bind to the server. 此参数只能指定使用/不使用 SSL 的简单绑定或 Negotiate 绑定。This parameter can only specify Simple bind with or without SSL, or Negotiate bind.

返回

Boolean

如果凭据有效,则为 true;否则为 falsetrue if the credentials are valid; otherwise false.

例外

当上下文类型为 Machine 时,options 参数必须指定 NegotiateThe options parameter must specify Negotiate when the context type is Machine.

注解

ValidateCredentials方法绑定到构造函数中指定的服务器。The ValidateCredentials method binds to the server specified in the constructor. 如果 usernamepassword 参数为 null ,则此方法将验证当前主体的默认凭据。If the username and password parameters are null, this method validates the default credentials for the current principal.

userName参数的格式必须为用户名 (例如mcampbell) ,而不是域**用户名或*用户名 @ 域*。The userName argument must take the form username (for example, mcampbell) rather than domain\username or username@domain.

适用于