简体   繁体   中英

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

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. 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. 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. You can find it: Application Pools --> Right click button under your service name --> Advance Settings Set "Load User Profile" true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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