2

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.

RevanthKrishnaKumar V.
  • 1,855
  • 1
  • 21
  • 34
Nandkumar
  • 21
  • 4

1 Answers1

-1

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.

Anatoliy
  • 36
  • 3
  • The question is not about just gaining the credentials, but gaining the credentials programatically. Your answer does not provide a solution to that problem – Takarii Aug 03 '16 at 10:16
  • I see , thanks. I will send programmatically example soon. – Anatoliy Aug 03 '16 at 11:49