Vista, IIS7, Windows Authentication and you

by Jesse 21. January 2008 08:14

I've been tasked with enabling Windows Authen to the current project I'm working on which "back in the old days" of IIS6 was uber easy -- tell it to use windows for the authentication, set your allow/deny groups, done, move along.  With IIS7 you get this really nasty rude surprise...

Server Error in '/someAppImWorkingOn' Application.

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web server's administrator for additional assistance.


Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833

Woah, ok, fine cousin Vinnie I'll just ...um, go over here for a while.  Jesh.

So I go bouncing around the net and I keep seeing posts about going into vista and enabling various stuff for IIS ...I go take a look and well well well, what do we have here?  Windows Authen, thank you very much ...along with all the other useful stuff.

Ooook, now let me guess, you have to go turn it on (yep!) so into the Inetmgr.msc, click on authentication, and no surprise...

Right click, enable, annnnddd back to the page.  But how do you know its working?  Here's a test I came up with on the fly to verify the stuff is doing its thing.  Just as a note, you have windows authen enabled and anonymous enabled for the following tests.

Go into your root page, whatever that may be (default.aspx?) and drop in a LoginName control onto the page (look under Login in your toolbox), drop it on the page somewhere obvious, the top works great.  Dump this into your web.config somewhere under <system.web>, you've probably seen this before...

<authentication mode="Windows"/>
<
authorization>
     <
deny users="?"/>
</
authorization>

so you've seen this, the ? disables all anonymous users.  Load your page up and you'll see <domainName>\<userName> on the screen (assuming you are on a domain).  Great, it works, now change <deny users="?"/>  to <deny users="*"/> (This'll disable ALL users) -- You'll get a prompt (!) and a nasty 401.2 error when you click cancel.  Switch back to the ? and go back into inetmgr and disable windows authen.  Refresh the page and you'll get the same 401.2 error.

I almost forgot, if you take away the <deny users="?"/> you'll see NO username at the top (its anonymous after all!)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

.Net | Coding | Tech | Security | Design

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic

Java

Currently working on ...
i did the hundred 
and some extra stuff

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother nor their dog's view in anyway.  At all.  Ever.

© Copyright 2007-2008