語言

PrincipalContext.ValidateCredentials 方法

定義

建立與伺服器的連線,並在連線成功時驗證指定的憑證。

多載

名稱 Description
ValidateCredentials(String, String)

建立與伺服器的連線,並回傳一個布林值,指定使用者名稱與密碼是否有效。

ValidateCredentials(String, String, ContextOptions)

建立與伺服器的連線,並回傳一個布林值,指定指定的使用者名稱與密碼是否有效。 此方法能快速驗證使用者名稱與密碼。

備註

userName此方法的兩個超載參數都必須採用 username(例如 mcampbell)的形式,而非 domain\username 或 username@domain。

ValidateCredentials(String, String)

來源:
Context.cs
來源:
Context.cs
來源:
Context.cs
來源:
Context.cs

建立與伺服器的連線,並回傳一個布林值,指定使用者名稱與密碼是否有效。

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

伺服器上驗證的用戶名稱。 有關格式 userName的更多資訊,請參閱備註區。

password
String

伺服器上驗證的密碼。

傳回

true 若憑證有效;否則 false。

備註

該 ValidateCredentials 方法綁定到建構子中指定的伺服器。 若 username 和 password 參數為 null,此方法驗證當前主體的預設憑證。

參數 userName 必須以 userName 形式(例如 mcampbell)而非 domain\username 或 username@domain。

適用於

ValidateCredentials(String, String, ContextOptions)

來源:
Context.cs
來源:
Context.cs
來源:
Context.cs
來源:
Context.cs

建立與伺服器的連線,並回傳一個布林值,指定指定的使用者名稱與密碼是否有效。 此方法能快速驗證使用者名稱與密碼。

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

伺服器上驗證的用戶名稱。 請參閱備註區以了解 的 userName格式資訊。

password
String

伺服器上驗證的密碼。

options
ContextOptions

一個或多個 ContextOptions 列舉的組合會決定綁定到伺服器的選項值。 此參數只能指定有無 SSL 的簡單綁定,或 Negotiate 綁定。

傳回

true 若憑證有效;否則 false。

例外狀況

options參數必須指定Negotiate上下文型態Machine為 。

備註

該 ValidateCredentials 方法綁定到建構子中指定的伺服器。 若 username 和 password 參數為 null,此方法會驗證當前主體的預設憑證。

該 userName 參數必須採用 username (例如 mcampbell)的形式,而非 domain\username 或 username@domain。

適用於