gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:00:33 25 4
gpt4 key购买 nike

在 IIS 下的 ASP.net 网站中使用 C# 从 Windows Credentials Store 问题中检索凭据我正在使用以下代码

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 始终为 null)我在我的控制台应用程序中使用了相同的代码并且工作正常。请让我知道任何需要遵循的特殊说明。提前致谢。

最佳答案

如果您使用 IIS 7,您可以尝试启用“加载用户配置文件”参数。您可以找到它:Application Pools --> 右键单击​​您服务名称下的按钮 --> Advance Settings将“加载用户配置文件”设置为真。

关于c# - 在 IIS 下的 ASP.net 网站中使用 C# 从 Windows 凭据存储中检索凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com