Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the default credentials?

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 ?

like image 816
Royi Namir Avatar asked Dec 21 '11 17:12

Royi Namir


People also ask

What is default credentials?

DefaultCredentials represents the system credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application.


1 Answers

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

System.Net.CredentialCache.DefaultNetworkCredentials

or

System.Net.CredentialCache.DefaultCredentials
like image 84
SuperOli Avatar answered Oct 21 '22 07:10

SuperOli