Getting default credentials?

I have an A.aspx page in my domain

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

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 on my website for a specific account.

the account is transferred by the operator:

  loHttp.UseDefaultCredentials = true; 

everything is good.....

However, I want to see these credentials (I need to get them)

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

 WindowsIdentity.GetCurrent().Name 

but I want to see the values ​​that are in UseDefaultCredentials ! sort of

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

How can i do this?

+4
source share
1 answer

I needed to do this, but in WinForms. It may be work for you:

 System.Net.CredentialCache.DefaultNetworkCredentials 

or

 System.Net.CredentialCache.DefaultCredentials 
+7
source

Source: https://habr.com/ru/post/1387432/


All Articles