Description: Description: http://www.monacaron.com/~mona/images/large/kerberos.jpg       Κέρβερος, the three-headed guard dog

 

 

Troubleshooting the 401.1 - Unauthorized: Access is denied due to invalid credentials

 

Trouble-shooting the 401.1 when an IIS website is set to using Windows Integrated / Negotiate (Kerberos or NTLMv2) authentication

in single hop and double hop scenarios

 

by vIISual.net(at)hotmail(dot)com

 

updated May 2010.  But this is unfinished.  There is a lot left to do on this page.

 

 

 

 

 

 

 

 

 

 

 

 

 

Confirm the error message.  There are several types of 401 errors.  The 401.1 is very different than the 401.2 and 401.3.  Here is the 401.1 as seen in the IE 7 browser:

 

You are not authorized to view this page

You do not have permission to view this directory or page using the credentials that you supplied.

Please try the following:

·         Contact the Web site administrator if you believe you should be able to view this directory or page.

·         Click the Refresh button to try again with different credentials.

HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials.
Internet Information Services (IIS)

Technical Information (for support personnel)

·         Go to Microsoft Product Support Services and perform a title search for the words HTTP and 401.

·         Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Authentication, Access Control, and About Custom Error Messages.

 

Here is an example of the 401.1 as seen in the IIS logs

 

 

#Software: Microsoft Internet Information Services 6.0

#Version: 1.0

#Date: 2010-04-22 14:36:47

#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status

2010-04-22 14:40:48 W3SVC1655145481 172.25.5.32 GET /admin.asp - 80 MYCORP\hobbsj 172.25.5.32 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+Trident/4.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) 401 1 0

 

The default location for IIS6 is c:\windows\system32\logfiles\w3svc.  For IIS7 it is c:\inetpupb\logs\logfiles\w3svc.  Note how the 401.1 shows up as 401 1 (status code substatus code).  This assumes that the IIS logging properties of the website in focus is set to log the sc-substatus code.

 

 

 

 

 

 

 

Some Client (IE) Considerations

 

 

 

Same Domain?

 

For both kerberos authentication and/or NTLMv2 authentication to work the client (Internet Explorer preferably) has to be joined to the domain that the web server is in.   (Or it has to be in a domain with proper trusts set up to/from the target domain.)

 

 

 

Unhindered Communication?

 

The client, the web server, and the domain controller (the KDC – key distribution center) need to be able to communicate with one another over certain ports.  If a firewall, for example, has port 88 or 464 locked down Kerberos authentication may not work.  NTLM may be able to work when those ports are locked down, however.   Still, don’t expect Windows authentication to work when the clients are anonymous clients hitting a webserver from across the internet.  The clients are not part of a trusted domain to begin with.  And what is more, the KDC is almost certainly protected by a firewall of some kind.   It is possible to occasionally get NTLM authentication to work for a client hitting a website across the internet because the client might get prompted for credentials and those credentials might be accepted.  However, at this point it would be better to rely on Basic Authentication with SSL rather than NTLM.   Neither NTLM nor Kerberos are meant to work across the internet.

 

 

Browser Version:

 

The client browser must be Internet Explorer v5.0 or higher--not Firefox, Netscape, Mozilla, etc. 

 

 

NTLM or Kerberos?

 

One thing that can be helpful is to confirm that the IE browser is set to be able to do Kerberos.  Click the IE Tools menu select “Internet Options” and select the Advanced Tab.  Scroll down to the setting for “Enable Integrated Windows Authentication.”   This should be checked by default.  If it is not check marked, you can expect your client to try to do NTLMv2 authentication but not attempt to do Kerberos authentication.   If you uncheck this and restart IE, you can test the authentication with NTLM.   If it works with NTLM but not with Kerberos that is sometimes good to know.

 

 

 

 

 

 

 

Which IE Zone?

 

Note whether the address of the website the client is trying to hit is or is not listed in the IE intranet zone list or the IE trusted sites list.    

 

Look in the lower right corner of IE after browsing to the website to see which Zone IE has recognized the website to be in.

 

 

 

 

 

 

In IE, select the Tools menu > Internet Options > Security Tab.

Select Intranet Sites

 

 

Click the “Custom Level” button. 

 

 

For NTLM and Integrated authentication methods to work, it is best that the IE client have “Automatic logon only in Intranet Zone” set (which it usually is by default unless a group policy has changed it) and for the URL that the client is browsing to to be listed in the “Local Intranet” zone list of the client.   Many people make the mistake of setting the site in the “Trusted sites” zone list.   But that is for internet sites, not intranet sites.  And the magic of the automatic logon is only going to occur if that site is in the local intranet site list.   If the website you’re browsing to has a period/dot in it, Internet Explorer is going to assume that the site belongs in the Internet zone (not the Local intranet) and will attempt to authenticate accordingly.   Don’t expect NTLM or Kerberos authentication to work if the address is an IP address (example:  http://64.113.15.3) or a fqdn of a server (example: http://webserver1.mydomain.local).   But if you add the address to the local intranet zone, you are one step closer. 

 

 

 

 

 

 

 

 

 

 

Tools

 

 

 

SETSPN

 

SetSPN (Windows 2000) – from the 2000 reskit… setspn-o.asp

 

SetSPN (Windows 2003) – kb 892777 – windows server 2003 service pack 1 32-bit support tools

         Check c:\program files\support tools\setspn.exe

 

Delegconfig v1                                andDelegconfig v2 Beta

 

Netmon or Wireshark

 

 

Kerbtray – can be run on the workstation to show which kerberos tickets it is holding

 

Authdiag (Win2003)

 

 

 

 

 

 

 

IIS Web Server Considerations

 

 

 

 

Confirm that “Windows Authentication” is set as the ONLY authentication method set in IIS.

 

 

IIS 7.x

 

 

 

IIS 6.0

 

 

 

 

 

 

 

 

(IIS 6) Does the AppPool Identity run with something other than the local “network service” account or the “local system” account?   If so, you’re going to need an SPN that matches the address that the clients are browsing to with the user account that the w3wp.exe is running as.  (But if you’re using the Predefined accounts of either Network Service or Local System, you do NOT need to add any SPNs.  These accounts use the existing host spn to decrypt the Kerberos ticket.  Additional SPNs can confuse the Kerberos ticket request process by the client.)  

 

 

 

 

 

 

 

 

Remove the server name

 

 

 

 

 

 

 

 

 

 

 

 

 

Service Principle Names (“SPNs”) Considerations

 

 

Use a tool (such as Setspn.exe, AuthDiag, or Delegconfig.zip) to check for missing or competing SPNs.  I’d recommend setspn.exe.

 

SPNs can be adjusted from any machine joined to the domain as long as the person using the tool is logged in as a domain administrator.

 

We need to check to see whether or not the right SPN actually exists.  We also need to check whether or not there are duplicate/competing SPNs. 

 

Download setspn from http://www.microsoft.com/downloads/details.aspx?FamilyID=5fd831fd-ab77-46a3-9cfe-ff01d29e5c46&displaylang=en

 

 

To list all the SPNs associated with a specific server, run this:

 

Setspn –L servername 

 

Setspn –L domain\useraccountname

 

ServiceAccount

  HTTP/[URL or A-Host-record]

 

Then must run iisreset

And log off and log on with client

 

 

 

Setspn –A HTTP/ fqdn.fqdn.com [host header value] DomainName\Username [target machine account name or the user account used by App Pool’s identity]

 

Domain\servername$

 

 

 

Do two different user accounts have ties to the same http\fqdn SPN?  If so, it’s a problem.

 

 

 

Example: 

Let’s say we have in DNS an (A)Host record for “MyGreatWebApp.” 

And let’s say the website we’re going to be browsing to is in an application pool configured with a domain account named “MyWebServiceAccount.”

Here is how you would add the needed SPN:

     Setspn –A HTTP/mygreatwebapp DomainName\Mywebserviceaccount

 

If you prefer to browse to the servername, however, the SPN would need to be added as follows:

     Setspn –A HTTP/servername DomainName\Mywebserviceaccount

 

The only potential problem here is that when using the servername the chance of having a duplicate/contentious SPN is more likely than if you use an SPN matching a (A) Host record.

 

 

 

 

 

 

 

 

 

 

 

NTAuthenticationProviders

 

From command line:   C:\inetpub\adminscripts\> cscript.exe adsutil.vbs GET w3svc/NTAuthenticationProviders.  

 

 

We expect to see “not set at this node” if no one has ever changed it.  In IIS6, this is set by default properly as “Negotiate,NTLM” in the mbschema.xml file rather than the metabase.xml file.  The GET may return an answer saying “not set at this node” and that’s an indication that it is all fine—it is set in the mbschema, just not in the metabase proper.   Even though it is set properly by default in IIS 6, it may be good to check with adsutil to make sure that no one changed it in the metabase.xml file.)   If it is not set to “Negotiate,NTLM” it can be so set with the following command:  Adminscripts\>cscript.exe adsutil.vbs SET w3svc/NTAuthenticationProvidersNegotiate,NTLM    (not “Negotiate, NTLM”—with a space after the comma)

 

 

Check the Security Event Log (start > Run > open: eventvwr) on the IIS server (and possibly on the DC as well?).  But may first need to increase Auditing level first. (Click here to see how to do this.)

 

 

 

 

 

 

 

Active Directory Considerations

 

 

 

If you need to do “double-hop” Kerberos authentication and have created the necessary SPNs, you’ll have the option to trust computer accounts and/or user accounts for delegation.  You’ll need to set up some delegation for the double-hop authentication to work.

 

Again, NTLM cannot do double-hops but Kerberos can.   By double-hop we mean the client to the web server is one hop and then from the web server to a backend server as the second hop.  To do double-hop authentication, you may need to begin by setting some SPNs and ensuring that the computer account and the user account are trusted for delegation in Active Directory Users and Computers.

 

 

 

Is the IIS web server trusted for delegation?

 

Open ADUC (Active Directory Users and Computers)

 

Find the IIS server’s computer account and go to its properties sheet

 

Generally we want the middle option of “Trust this computer for delegation to specified services only”

 

 

 

In some circumstances the configurable account the Application Pool is configured to use may also need to be trusted for delegation.  This also should be set in Active Directory Users and Computers, only for a user account rather than a computer account.

 

 

 

 

 

 

 

 

 

 

 

 

Additional Documentation

 

 

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/security/tkerbdel.mspx

Troubleshooting Kerberos Delegation

 

You receive an "HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials" error message when you try to access a Web site that is part of an IIS 6.0 application pool

http://support.microsoft.com/default.aspx?scid=kb;EN-US;871179

 

How to configure SQL Server 2005 Analysis Services to use Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;917409

 

TechNet Support WebCast: Configuring Microsoft SQL Server 2005 Analysis Services for Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;916962

 

319723  How to use Kerberos authentication in SQL Server

http://support.microsoft.com/default.aspx?scid=kb;EN-US;319723

 

325894  HOW TO: Configure Computer Accounts and User Accounts So That They Are Trusted for Delegation in Windows Server 2003 Enterprise Edition

http://support.microsoft.com/default.aspx?scid=kb;EN-US;325894

 

326985  HOW TO: Troubleshoot Kerberos-Related Issues in IIS

http://support.microsoft.com/default.aspx?scid=kb;EN-US;326985

 

828280  How to configure an Analysis server computer to use Kerberos authentication in SQL Server 2000

http://support.microsoft.com/default.aspx?scid=kb;EN-US;828280

 

840219  You may not be able to connect to a SQL Server that is running on a Windows Server 2003 computer by using Windows authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;840219

 

907272  Kerberos authentication and troubleshooting delegation issues

http://support.microsoft.com/default.aspx?scid=kb;EN-US;907272

 

917409  How to configure SQL Server 2005 Analysis Services to use Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;917409

 

 

911149 - Error message in Internet Explorer when you try to access a Web site that requires Kerberos authentication on a Windows XP-based computer: "HTTP Error 401 - Unauthorized: Access is denied due to invalid credentials"

http://support.microsoft.com/default.aspx?scid=kb;EN-US;911149

(explains why you’ll want to use an A record rather than an Alias record in dns)

 

892777 - Windows Server 2003 Service Pack 1 Support Tools

 http://support.microsoft.com/default.aspx?scid=kb;EN-US;892777

(Tells how to get the SetSpn utility)

 

917409 - How to configure SQL Server 2005 Analysis Services to use Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;917409

 

916962  - TechNet Support WebCast: Configuring Microsoft SQL Server 2005 Analysis Services for Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;916962

 

909801 - How to make sure that you are using Kerberos authentication when you create a remote connection to an instance of SQL Server 2005

http://support.microsoft.com/default.aspx?scid=kb;EN-US;909801

 

You receive an "HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials" error message when you try to access a Web site that is part of an IIS 6.0 application pool

http://support.microsoft.com/default.aspx?scid=kb;EN-US;871179

 

 

http://www.zeroshell.net/eng/kerberos/Kerberos-operation/

Kerberos Authentication Protocol

 

 

262177           How to enable Kerberos event logging

http://support.microsoft.com/default.aspx?scid=kb;EN-US;262177

 

What do security event logs say on the MS SQL machine?  (may need to increase auditing first)

 

917409  How to configure SQL Server 2005 Analysis Services to use Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;917409

 

916962  TechNet Support WebCast: Configuring Microsoft SQL Server 2005 Analysis Services for Kerberos authentication

http://support.microsoft.com/default.aspx?scid=kb;EN-US;916962

 

 

909801 How to make sure that you are using Kerberos authentication when you create a remote connection to an instance of SQL Server 2005

http://support.microsoft.com/default.aspx?scid=kb;EN-US;909801

 

 

 

 

 

Old Information:

 

NSLOOKUP

From command line, run an NSLOOKUP against the address used to access the site. If the word “ALIAS” is returned, then the dns record is a CNAME record rather than an (A) Host record.   Ideally we’ll want to use a host record here since there are limitation with IE/wininet (see kb 911149) which affect (confuse) Kerberos ticket request building from the client side.

 

 

 

911149           Error message in Internet Explorer when you try to access a Web site that requires Kerberos authentication on a Windows XP-based computer: "HTTP Error 401 - Unauthorized: Access is denied due to invalid credentials"

http://support.microsoft.com/default.aspx?scid=kb;EN-US;911149

 

938305           Error message when you try to log on to a Web site that requires Kerberos authentication by using Internet Explorer 7 on a Windows XP SP2-based computer: "Access is denied due to invalid credentials"

http://support.microsoft.com/default.aspx?scid=kb;EN-US;938305

 

 

 

 

 

 

 

 

 

NETMON

When in doubt, install netmon on the client machine and the web server and get simultaneous netmon captures while reproducing the 401.1.

 

KERBTRAY

Can run kerbtray here to see if made ticket with a competing SPN

 

 

Tip:   try making it a habit of locking and unlocking the workstation to purge previous kerberos tickets.

 

 

 

 

If it seems like it should be working, but you’re still getting a 401.1, don’t forget the DisableLoopBackCheck possibility (kb896861) especially if using host headers and if nothing works and if Win2003 is on SP1 or higher.