Search code examples
c#active-directory.net-corewindows-authentication

Why did user.identity.name case sensitivity change in c#?


So I am working with a .NET Core app v1.0 in C#, it uses windows authentication.

Last time I used it on 14/02/2017. But today (16/02/2017) it stopped working properly because User.Identity.Name started to return case sensitive user name from MS Active Directory. So it went from "DOMAIN\jdoe" to "DOMAIN\JDoe" in the span of 1 day.

What possible reasons could make it suddenly change?


Solution

  • I believe the reason has to do with Active Directory changes rather than something in your code.

    At any case, it's best practice to allways upper or lower case you usernames:

    User.Identity.Name.ToLower();
    User.Identity.Name.ToUpper();