简体   繁体   English

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

[英]Retrieve Credentials from Windows generic 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 从Windows Credentials中检索凭据在IIS下的ASP.net网站中使用C#存储问题我正在使用以下代码

Local machine and windows 10 IIS its working fine. 本地机器和Windows 10 IIS其工作正常。 but when i try to hosting in windows server 2012 R2 not working. 但当我尝试在Windows Server 2012 R2托管不工作。 My code: 我的代码:

    var cm = new Credential();
cm.Target = "targetname";
cm.Type = CredentialType.Generic;
if (!cm.Exists())
{
    Console.WriteLine("cm is null");
}
cm.Load();
Console.WriteLine(cm.Password);
Console.WriteLine(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总是为null)我在我的控制台应用程序中使用相同的代码并且工作正常。 Please let me know any special instruction need to follow. 请让我知道需要遵循的任何特殊说明。

You should switch "Load User Profile" parameter of IIS App Pool to true. 您应该将IIS App Pool的“加载用户配置文件”参数切换为true。 Then your code should start working. 那么你的代码应该开始工作了。

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

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