Windows Auth and "Error: HttpError: Windows Auth Failed"

Hey ServiceStack,

I am having an issue with the AspNetWindowsAuthProvider. My configuration is setup like the following:

new AspNetWindowsAuthProvider(this){
    AllowAllWindowsAuthUsers = true,
    LoadUserAuthFilter = LoadUserAuthInfo

public void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
    if (userSession == null)

    using (var pc = new PrincipalContext(ContextType.Domain))
        var user = UserPrincipal.FindByIdentity(pc, userSession.UserAuthName);

        tokens.DisplayName = user.DisplayName;
        tokens.Email = user.EmailAddress;
        tokens.FirstName = user.GivenName;
        tokens.LastName = user.Surname;
        tokens.FullName = string.IsNullOrWhiteSpace(user.MiddleName)
            ? "{0} {1}".Fmt(user.GivenName, user.Surname)
            : "{0} {1} {2}".Fmt(user.GivenName, user.MiddleName, user.Surname);
        tokens.PhoneNumber = user.VoiceTelephoneNumber;

Based on the examples I have seen and research I have done so far, this should be all that I need to enable authentication via Windows Authentication. However, I only get “Error: HttpError: Windows Auth Failed” responses when I try to hit any service with an [Authenticate] attribute.

Any ideas as to why this is occuring?

Thank you,

Do you have Windows Auth enabled? To be clear Windows Auth happens in IIS/ASP.NET before the request reaches ServiceStack, the AspNetWindowsAuthProvider therefore just checks user.Identity.IsAuthenticated.

Without any extra info like the StackTrace it’s not clear what the issue is, maybe its your LoadUserAuthInfo impl, have you tried debugging it to see if it gets called?

Yes, Windows Authentication is enabled at the IIS level as well as in the Web.config. My username is “” when I debug, which is weird. I am using IE to test this, so I expect the credentials to pass through.

You do bring up a good point though, at no point do I break on my first line of the LoadUserAuthInfo. I am guessing that is because it doesn’t even get to that point. The first issue is that my Principle Username is “” and I cannot figure out why.

I’m going to continue to dig into the issue. Let me know if you have any ideas. I appreciate your help.


To make debugging easier I’d take a local copy of AspNetWindowsAuthProvider and register/debug that so you can step thru the impl.

Will do and I’ll keep you updated when I fix the issue.

Well, as I thought, it was a configuration issue with IIS. This machine was setup wqithout IIS being installed on it. When I installed IIS, I ran aspnet_regiis -ir … GAAAAAAH. This left the mappings to the current (.NET v3.5) version of .NET that was installed. When I ran aspnet_regiis -r to replace the mappings to .NET v4, Windows Auth started to work as expected. Sorry for the clutter on the forum and thanks again for your assistance.


Cool, glad it’s sorted!