Question

User names on Windows are case-insensitive (but case-preserving), so you can log in both as UserName and uSERnAME. However, "case" is different for different locales — which locale does Windows use to decide that the supplied user name is the same as one in the account database?

I believe it is the Invariant Locale, and that doesn't depend on anything in the "Language and Regional Options" dialog, but I may be wrong. In any case, I would appreciate something like an MSDN article for confirmation (or refutation).

Was it helpful?

Solution

Windows uses "UpCase and Binary Compare" approach to compare file names (see Comparing Unicode file names the right way and Win32 File Name Comparison), so there's a high chance that user names follow the same comparison rules (user folders created under "Users" folder are part of the file system). Comparison using invariant locale should be pretty close to it, but I'm not sure.

User locale, user UI locale etc. are definitely not used, because that would make opersting system objects depend on user settings.

OTHER TIPS

UI Language is what decides this. See this MSDN blog post about the differences. While it doesn't specifically mention usernames, it does say that:

The UI language in Windows is the language the system uses to communicate with the user.

That tells me that prior to logging on, this is the language/locale settings that Windows presents to the user. That way one could type a username using characters on their Afrikaans or Japanese keyboard, as long as the system's UI language is set to Afrikaans or Japanese.

Also, this article says that (under the Windows Desktop App Development breadcrumb/tree)

The system uses Unicode exclusively for character and string manipulation.

Now, that said - google tells me (as you mentioned) that default Windows handling of usernames is "case-aware" but not "case-sensitive", meaning that it will store the case as specified when a user is created, but doesn't care about it when checking credentials. Active Directory also appears to be case-insensitive.

From that I read that there is some hard-coded case-change of the entered and saved username during authentication, which means that there must be some hard-coded assumption of UTF-8 characters if the UI language is set to en-US (and probably any en-* language/locale). I don't know if it would do this for any "western"-based locale, though; I couldn't find anything on that.

It depends on UI language. Not sure about others, but one of the most problematic languages of "cases" is Turkish. Because all other languages have lower letter "i" with a dot on it but in Turkish we have "ı" as well as "i". We also have capitals "I" and "İ". So it requires a spesification itself.

Referring to wikipedia, usernames are used with environment variables which are not case sensitive in Windows. But it is "case-aware" as klugerama said.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top