views:

569

answers:

2

In this extremely helpful summary from Mike O'Brien

http://blog.mike-obrien.net/PermaLink,guid,5e975b20-7b05-472f-bd80-04028ab8b6fa.aspx

he gives an overview of how IIS 7 deals with authentication for different settings (I couldn't find a similar summary for IIS 6, which is the version we are using). We have set the authentication to Integrated Windows Authentication; anonymous access is turned off and I am not using impersonation. The asp.net app sits in an intranet, but I have no control (and very little knowledge) of how many domains there are, how they interact with each other etc.etc. According to the article above I should get the same user information for all three of:

Thread.CurrentPrincipal.Identity
HttpContext.Current.User.Identity
Request.LogonUserIdentity

I do get the correct user, but the casing is different from the AD name. So my question is: if

Thread.CurrentPrincipal.Identity

(which is what I am using) gives the right AD name, but displays a different casing to AD, is that most likely an issue with Thread.CurrentPrincipal.Identity, with the intranet/domain settings, or differences between IIS 6 & IIS 7?

(apologies for the vague nature of this question: I'm just trying to look for suggestions as where best to look and/or input as to whether there is something inherently unwise about using Thread.CurrentPrincipal.Identity).

EDIT: update for IIS 6 - according to this link

http://msdn.microsoft.com/en-us/library/aa302377.aspx

I should be getting DOMAIN\username for IIS 6 as well, so no difference there. Could the issue be related to how Kerberos/NTLM interact with IIS?

EDIT #2: The problem can be summarised thus:

I am displayed as e.g. DOMAIN\joebloggs in AD. I logged in as joebloggs. But the credentials I get back from a (successful) authentication using Thread.CurrentPrincipal.Identity show DOMAIN\JoeBloggs. Where could that be coming from?

A: 

The user name in this case is supplied by the client. The authentication mechanism verifies that the identity can be confirmed, but it does not replace the user-supplied name with the as-stored name from AD, so there is no reason to expect the casing to match.

Nicole Calinoiu
@Nicole: thank you for your reply. But what exactly do you mean by "client": IIS, Operating system...? My problem is that the "user-supplied name" seems to be neither the AD name, nor the login name (i.e. what the user typed), since changing either or both of these does not solve the problem, even with IIS restarted, caches emptied, different machines used etc.etc.
davek
...and according to the Mike O'Brien link, I should - for my IIS setup - be getting either DOMAIN\username or HOST\username (implying, I think, the casing indicated by those elements).
davek
There is no mention whatsoever of casing in the Mike O'Brien article, so I'm not sure where you got the idea that it's in any way relevant.
Nicole Calinoiu
As for the "client", I mean the browser (and the OS behind it) that is requesting a resource from your web server.Let's say you're supporting only NTLM authentication on the server, and your client is IE running on Windows, with the user already logged into Windows under a domain account. When the user logged onto his client machine, he supplied the user name "somedomain\bob" (using exactly that casing). Assuming that this account is authorized to use your page, that's the casing you should be seeing.
Nicole Calinoiu
If I've understood you correctly, you're saying that I can manipulate the casing I see by what I enter when I login: somedomain\bob or somedomain\Bob or somedomain\bOb etc.etc. But I've tried that and it doesn't make any difference: the credentials I see are not merely what I typed in on login: they have been persisted somewhere, and I can't understand where.
davek
True, O'Brien didn't mention casing, but I made the (perhaps wrong) assumption from his article that I am getting back AD/NTLM/Kerberos credentials (in whatever casing they happen to have been saved or persisted).
davek
A: 

It turns out that I was not getting accurate information from the client site: i.e. the authentication is happening the way I had understood it (i.e. ASP.Net: lookup and return from AD; ASP: handed off to IIS) and the unexpected casing was down to caching issues and not down to the authentication mechanism.

davek