簡體   English   中英

在 IIS 下的 ASP.net 網站中使用 C# 從 Windows Credentials Store 檢索憑據

[英]Retrieve Credentials from Windows Credentials Store using C# in ASP.net website under IIS

在 IIS 下的 ASP.net 網站中使用 C# 從 Windows 憑據存儲問題中檢索憑據我使用以下代碼

var cm = new Credential();
cm.Target = "targetname";
cm.Type = CredentialType.Generic;
if (!cm.Exists())
{
    Console.WriteLine("cm is null");
}
cm.Load();
Console.WriteLine("Password: " + cm.Password);
Console.WriteLine("Username: " + cm.Username);'

以上代碼在 IIS 下的 windows server 2012 R 上運行。 但是上面的代碼無法檢索用戶名和密碼。(cm 始終為空)我在控制台應用程序中使用了相同的代碼並且工作正常。 請讓我知道任何需要遵循的特殊說明。 提前致謝。

如果您使用 IIS 7,您可以嘗試啟用“加載用戶配置文件”參數。 您可以找到它:應用程序池--> 在您的服務名稱下右鍵單擊按鈕--> 高級設置將“加載用戶配置文件”設置為true。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM