FormsAuthenticationConfiguration.Credentials 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得使用者名稱和密碼的 FormsAuthenticationCredentials 集合。
public:
property System::Web::Configuration::FormsAuthenticationCredentials ^ Credentials { System::Web::Configuration::FormsAuthenticationCredentials ^ get(); };
[System.Configuration.ConfigurationProperty("credentials")]
public System.Web.Configuration.FormsAuthenticationCredentials Credentials { get; }
[<System.Configuration.ConfigurationProperty("credentials")>]
member this.Credentials : System.Web.Configuration.FormsAuthenticationCredentials
Public ReadOnly Property Credentials As FormsAuthenticationCredentials
屬性值
FormsAuthenticationCredentials 集合,此集合含有使用者名稱和密碼。
- 屬性
範例
下列程式碼範例示範如何存取 Credentials 屬性。 請參閱類別主題中的 FormsAuthenticationConfiguration 程式碼範例,以瞭解如何取得區段。
// Get the current Credentials.
FormsAuthenticationCredentials currentCredentials =
formsAuthentication.Credentials;
StringBuilder credentials = new StringBuilder();
// Get all the credentials.
for (System.Int32 i = 0; i < currentCredentials.Users.Count; i++)
{
credentials.Append("Name: " +
currentCredentials.Users[i].Name +
" Password: " +
currentCredentials.Users[i].Password);
credentials.Append(Environment.NewLine);
}
' Get the current Credentials.
Dim currentCredentials _
As FormsAuthenticationCredentials = _
formsAuthentication.Credentials
Dim credentials As New StringBuilder()
' Get all the credentials.
Dim i As System.Int32
For i = 0 To currentCredentials.Users.Count - 1
credentials.Append(("Name: " + _
currentCredentials.Users(i).Name + _
" Password: " + _
currentCredentials.Users(i).Password))
credentials.Append(Environment.NewLine)
Next i
備註
屬性 Credentials 會取得表單型驗證期間要使用的使用者名稱和密碼。
注意
需要安全性時,您應該使用替代方式來儲存使用者名稱和密碼;例如,在資料庫存放區中。 如果您決定使用此集合,您應該使用提供的加密設備。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應