c# - 获取默认凭据?

标签 c# asp.net impersonation credentials

我的域中有页面 A.aspx

此页面(在其 c# 代码中)向另一个页面发出请求。(B.aspx)。 - 这也在我的域中

整个站点都在windows认证

HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create("http://mydom.com/b.aspx");
loHttp.UseDefaultCredentials = true;
loHttp.Timeout = 100000;
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = Encoding.GetEncoding("UTF-8");  // Windows default Code Page
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
return lcHtml;

我在我的网站中使用模拟特定帐户。

账户正在被转账的语句:

 loHttp.UseDefaultCredentials = true;

一切都很好......

但是,我想查看这些凭据(我需要他们的“get”)

我知道当前线程帐户(受模拟影响)由:

WindowsIdentity.GetCurrent().Name

但我想查看 UseDefaultCredentials 中的值! 类似

DefaultCredentials.getCurrent.username
DefaultCredentials.getCurrent.password...

我该怎么做?

最佳答案

我不得不这样做,但在 WinForms 中。它可能也适合您:

System.Net.CredentialCache.DefaultNetworkCredentials

System.Net.CredentialCache.DefaultCredentials

关于c# - 获取默认凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8594218/

相关文章:

c# - Web Api Controller 路由随机停止工作

asp.net - 模拟ASP.NET中的成员资格用户

c# - 动态 where 子句 Entity Framework 3.5

c# - RichTextBox 作为输出和 TextBox 作为一种形式的输入,如何在保持对输入的关注的同时从输出中进行选择?

javascript - 从razor中的javascript访问对象

javascript - 将文件从 JQuery Ajax 发送到 C# Webmethod

c# - 将 `List<string>` 转换为逗号分隔的字符串

asp.net - 在 ASP.Core 中找不到 WindowsImpersonationContext 和 Impersonate()

c# - 将文件复制到我无权访问的网络共享

c# - 使用 Epplus 读取 Excel 文件时出现 STG_E_WRITEFAULT