When I debug my website locally using IIS Express + Windows Authentication, my authorization and custom Roles work correctly - my domain\username shows up by using Environment.UserDomainName and Environment.UserName, and my [Authorize(Roles = "MyCustomRole")]
works along with the User.IsInRole calls in Razor.
But when I deploy my website to a production IIS 7.5 instance, my domain\username shows up as NT Authority\Local System (or something like that, at home at the moment so I can't verify the exact text, but that's close). Also, none of my User.IsInRole checks
work, and my [Authorize] attributes do not work either. I've followed lots of setup docs regarding IIS 7.5 and Windows Authentication with ASP.NET, but it doesn't seem to be holding. Any ideas?
Very glad to hear that you have resolved your issue and thank you for sharing your solution which will help others who meet the same issue. Welcome to Asp.net forum again.
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
mariocatch
Member
18 Points
44 Posts
Windows Authentication + IIS 7.5 + [Authorize] Not Working?
Nov 27, 2012 01:12 PM|LINK
Hello,
When I debug my website locally using IIS Express + Windows Authentication, my authorization and custom Roles work correctly - my domain\username shows up by using Environment.UserDomainName and Environment.UserName, and my [Authorize(Roles = "MyCustomRole")] works along with the User.IsInRole calls in Razor.
But when I deploy my website to a production IIS 7.5 instance, my domain\username shows up as NT Authority\Local System (or something like that, at home at the moment so I can't verify the exact text, but that's close). Also, none of my User.IsInRole checks work, and my [Authorize] attributes do not work either. I've followed lots of setup docs regarding IIS 7.5 and Windows Authentication with ASP.NET, but it doesn't seem to be holding. Any ideas?
mariocatch
Member
18 Points
44 Posts
Re: Windows Authentication + IIS 7.5 + [Authorize] Not Working?
Nov 27, 2012 02:32 PM|LINK
Note,
If I set AnonymousAuthentication to Disabled, and change my Environment.UserDomainName \ Environment.UserName to User.Identity.Name, it seems to work.
I am noticing some oddities in my custom role authentication but that is a separate issue.
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: Windows Authentication + IIS 7.5 + [Authorize] Not Working?
Nov 30, 2012 05:07 AM|LINK
Hi,
Very glad to hear that you have resolved your issue and thank you for sharing your solution which will help others who meet the same issue. Welcome to Asp.net forum again.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store