Empty CredentialCache.DefaultCredentials

G

Guest

I have an ASP.NET 2.0 site running on XP SP2 that uses Windows Integrated
Authetication. In web.config I have the following:

<system.web>
<authentication mode="Windows" />
<identity impersonate="true" />

<authorization>
<allow roles="DOMAIN\Group" />
<deny users="*" />
</authorization>
</system.web>

Now then, if I put the following in Page_Load of default.aspx:

if (HttpContext.Current.User.IsInRole("DOMAIN\\Group"))
{
Response.Write("in role");
}

.... "in role" will be displayed in the browser (so the Integrated
Authentication seems to work OK).

And if I do this:
Response.Write(HttpContext.Current.User.Identity.Name);

.... "DOMAIN\Username" will be displayed.

However, if I put the following in Page_Load instead:

NetworkCredential cred =
(NetworkCredential)CredentialCache.DefaultCredentials;
Response.Write(cred.UserName);

.... nothing (an empty string) is displayed in the browser.
Why is that? Why are the Domain, UserName and Password properties of the
NetworkCredential object all empty? Is this my credential still a valid one
even though nothing is displayed?
 
Joined
Apr 10, 2007
Messages
1
Reaction score
0
Re

Discovered that defaultcredentials is only valid if impersonate is enabled
for the asp app. i havent tried it myself, coz i am building a windows applcation connecting to a server url on the network, and am still trying to by pass it myself. but maybe this solution could help u out
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top