简体   繁体   English

在 IIS 下的 ASP.net 网站中使用 C# 从 Windows Credentials Store 检索凭据

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

Retrieve Credentials from Windows Credentials Store problem using C# in ASP.net website under IIS I am using following code在 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);'

Above code running on windows server 2012 R under IIS.以上代码在 IIS 下的 windows server 2012 R 上运行。 But above code is not able to retrieve username and password.(cm is null always) I used same code in my console application and works fine.但是上面的代码无法检索用户名和密码。(cm 始终为空)我在控制台应用程序中使用了相同的代码并且工作正常。 Please let me know any special instruction need to follow.请让我知道任何需要遵循的特殊说明。 Thanks in advance.提前致谢。

If you use IIS 7 you could try to enable "Load User Profile" parameter.如果您使用 IIS 7,您可以尝试启用“加载用户配置文件”参数。 You can find it: Application Pools --> Right click button under your service name --> Advance Settings Set "Load User Profile" true.您可以找到它:应用程序池--> 在您的服务名称下右键单击按钮--> 高级设置将“加载用户配置文件”设置为true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM