Getting the default credentials?

爷,独闯天下 提交于 2019-12-10 09:33:09

问题


I have page A.aspx in my domain

this page (in its c# codes) makes a request to another page.(B.aspx). - which is in my domain also

the whole site is in windows authentication

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;

Im using impersonation in my web site to a specific account.

the account is being transferred by the statement :

 loHttp.UseDefaultCredentials = true;

all is fine.....

However, I want to see those credentials ( I need their "get")

I know that the current thread account(being affected by impersonation)is given by :

WindowsIdentity.GetCurrent().Name

but I want to see the values that in the UseDefaultCredentials ! something like

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

how can I do that ?


回答1:


I had to do this but in WinForms. It might be work for you too:

System.Net.CredentialCache.DefaultNetworkCredentials

or

System.Net.CredentialCache.DefaultCredentials


来源:https://stackoverflow.com/questions/8594218/getting-the-default-credentials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!