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?
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?