WebTopics

IIS and ASP.NET Information and Tips from Microsoft Developer Support

Service Principal Name (SPN) checklist for Kerberos authentication with IIS 7.0/7.5

Service Principal Name (SPN) checklist for Kerberos authentication with IIS 7.0/7.5

Rate This
  • Comments 27

This post is more about the confusion that may arise around SPNs for setting up Kerberos authentication in IIS 7.0. IIS 7.0 has a new Kernel-mode authentication feature using which the ticket for the requested service is decrypted using Machine account (Local system) of the IIS server. It no longer depends upon the application pool Identity for this purpose by default and in turn improves the performance.

Here is how it looks like.

image

image

So what does this mean?

You no longer need to worry about the correlation between HTTP SPNs and the Application pool Identity that was required in the earlier version i.e. IIS 6.0. But that's not blindly true. There has been some confusion whether we don't have to care at all about SPNs or may have to depending upon the settings. Here is a checklist to give more clarity for different scenarios that you may fall under:

SCENARIO 1a

IIS 7.0 Web Site/Application  
Authentication Integrated Windows authentication
Application Pool Identity NETWORK SERVICE
Kernel-Mode authentication Enabled (<attribute name="useKernelMode" type="bool" defaultValue="true" /> in the ApplicationHost.config file)
Site URL Accessed with the NetBIOS name, like http://<myIISserver-NetBIOS-name>/Default.aspx

SPNs will be required ONLY for the IIS machine account:

HOST/<myIISserver-NetBIOS-name>
HOST/<myIISserver-NetBIOS-name.fully-qualified-domainname> for e.g. HOST/myIISserver.mydomain.com

***Note: By default HOST/<myIISserver-NetBIOS-name> and HOST/<myIISserver-NetBIOS-name.fully-qualified-name> is already added for the machine account when a machine is added to a domain and HTTP forms a part of HOST. So you may not have to do anything special here for SPNs. Everything should be set by default.

You can check the set of existing SPNs for the machine account by running the following command:

> Setspn.exe -L <myIISserver-NetBIOS-name> or directly using a Snap-in like Adsiedit.msc.

SCENARIO 1b

IIS 7.0 Web Site/Application  
Authentication Integrated Windows authentication
Application Pool Identity Custom account for e.g. Domain1\Username1
Kernel-Mode authentication Enabled (<attribute name="useKernelMode" type="bool" defaultValue="true" /> in the ApplicationHost.config file)
Site URL Accessed with the NetBIOS name, like http://<myIISserver-NetBIOS-name>/Default.aspx

The SPN requirements remain the same as above. You don't have to add SPNs like http/<myIISserver-NetBIOS-name> for the Domain1\Username1 unlike in IIS 6.0 (where we had to add an SPN of the form http/<myIISserver-NetBIOS-name> for the Application Pool identity).

SPNs will be required ONLY for the IIS machine account:

HOST/<myIISserver-NetBIOS-name>
HOST/<myIISserver-NetBIOS-name.fully-qualified-domainname> for e.g. HOST/myIISserver.mydomain.com

***Note: By default HOST/<myIISserver-NetBIOS-name> and HOST/<myIISserver-NetBIOS-name.fully-qualified-name> is already added for the machine account when a machine is added to a domain and HTTP forms a part of HOST. So you may not have to do anything special here for SPNs. Everything should be set by default.

You can check the set of existing SPNs for the machine account by running the following command:

> Setspn.exe -L <myIISserver-NetBIOS-name> or directly using Snap-in like Adsiedit.msc.

SCENARIO 2a

IIS 7.0 Web Site/Application  
Authentication Integrated Windows authentication
Application Pool Identity NETWORK SERVICE
Kernel-Mode authentication Enabled (<attribute name="useKernelMode" type="bool" defaultValue="true" /> in the ApplicationHost.config file)
Site URL Accessed with a Custom Host name, like http://www.mysite.com


SPNs will be required ONLY for the IIS machine account in the following format:

HTTP/<site-custom-name> for e.g. HTTP/www.mysite.com

You can add an SPN using Setspn.exe like

> Setspn -a http/<site-custom-name> <myIISserver-NetBIOS-name> 

where <myIISserver-NetBIOS-name> is the IIS machine account and <site-custom-name> is the custom host/host header name for the Web Site URL.

e.g. > Setspn -a http/www.mysite.com <myIISserver-NetBIOS-name>
*The command is NOT case sensitive

You can check the existing set of SPNs for the machine account by running the following command:

> Setspn.exe -L <myIISserver-NetBIOS-name>

 

SCENARIO 2b

IIS 7.0 Web Site/Application  
Authentication Integrated Windows authentication
Application Pool Identity Custom account for e.g. Domain1\Username1
Kernel-Mode authentication Enabled (<attribute name="useKernelMode" type="bool" defaultValue="true" /> in the ApplicationHost.config file)
Site URL Accessed with a Custom host/Host header name, like http://www.mysite.com


SPNs will be required ONLY for the IIS machine account and NOT for Domain1\Username1 account unlike in IIS 6.0.

HTTP/<site-custom-name> for e.g. HTTP/www.mysite.com

You can add an SPN using Setspn.exe like

> Setspn -a http/<site-custom-name> <myIISserver-NetBIOS-name> where <myIISserver-NetBIOS-name> is the IIS machine account and <site-custom-name> is the custom host/host header name for the Web Site URL.

e.g. > Setspn -a http/www.mysite.com <myIISserver-NetBIOS-name>
*The command is NOT case sensitive  

You can check the existing set of SPNs for the machine account by running the following command:

> Setspn.exe -L <myIISserver-NetBIOS-name>

 

Special case of running IIS 7.0 in a WEB FARM

If you are running IIS 7.0 server in a Web farm the KDC will not know in advance which individual server the request may go to and hence ticket decryption may fail. Hence in such a scenario instead of registering SPNs under a specific machine account use a domain account. I am not a SharePoint guy but based on what I have read on the Web this scenario is also applicable to a single SharePoint server configuration.

There are two ways to go:

Either

Disable Kernel mode authentication and follow the general steps for Kerberos as in the previous IIS 6.0 version. Refer this

Or,

[Recommended for Performance reasons]

Let Kernel mode authentication be enabled and the Application pool's identity be used for Kerberos ticket decryption. The only thing you need to do here is:

1. Run the Application pool under a common custom domain account.

2. Add this attribute "useAppPoolCredentials" in the ApplicationHost.config file.

<system.webServer>
   <security>
      <authentication>
         <windowsAuthentication enabled="true" useKernelMode="true" useAppPoolCredentials="true" />
      </authentication>
   </security>
</system.webServer>

Remember there is no GUI setting for this. You need to modify the ApplicationHost.config file from

<%SystemDrive%>/Windows/System32/inetsrv/config folder on the IIS 7.0 machine.

3. Add the SPNs in the form:

http/<virtualhost-name> and

http/<virtualhost-name.fully-qualified-name>  for the Application Pool Identity.

Ensure that we don't have such an entry for SPNs for any other account including IIS server machine account.

*If we have the same SPN mapped to multiple accounts (be it a machine or an user account) it leads to Duplicate SPNs and will break Kerberos.

Hope this helps!

Cross Posted from here

Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post
  • There's a white paper published on Microsoft Downloads (Configuring Kerberos Authentication for Microsoft SharePoint 2010 Products) that states:

    !Verify Kernel Mode Authentication is disabled

    Kernel mode authentication is not supported in SharePoint Server 2010. By default all SharePoint Web Applications should have Kernel Mode Authentication disabled by default on their corresponding IIS web sites. Even in situations where the web application was configured on an existing IIS web site, SharePoint will disable kernel mode authentication as it provisions a new web application on the existing IIS site."

    but this post say's to ehable it?

  • Since the SPN is now registered with the machine account, you may want to mention that the machine account need be marked as "Trust this computer for delegation to any service (Kerberos only)" or "Trus this computer to delegation to specified services only". I bet it will fix many people's problems here.

  • What does it mean...

    --------------------

    Add the SPNs in the form:

    http/<virtualhost-name> and

    http/<virtualhost-name.fully-qualified-name>  for the Application Pool Identity.

    ---------------------

    Where is this supposed to be added? In the ApplicationHost.config file ? If yes then where in that file?

    thanks.

  • @Roy Davis

    Where is this supposed to be added?

    You don't add those lines to a file.   It is simply showing you the syntax when issuing the command setspn,exe .  

    Example:

    setspn.exe http/<virtualhost-name>

    setspn.exe http/<virtualhost-name.fully-qualified-name>

  • @Shaun @Roy Davis

    This means that you need to had following SPNs on the service account eg: Domain/Username on which Application Pool is running.

    setspn.exe http/<virtualhost-name>

    setspn.exe http/<virtualhost-name.fully-qualified-name>

  • @Shaun

    Use asked this question:-

    In the ApplicationHost.config file ? If yes then where in that file?

    You can find this file in following location:-

    Start -> Run ->  %windir%\system32\inetsrv\config\

    I hope that will help...

  • The article below shows the easy way to set up the ApplicationHost.config file:

    blogs.technet.com/.../useapppoolcredentials-true-with-kerberos-delegation-on-2008.aspx

  • Updating to the UseAppPoolCredentials can also be scripted out using the appcmd.exe program as per the steps in this article, technet.microsoft.com/.../dd759186.aspx, i.e.

    "Set the IIS useAppPoolCredentials value to True

    1.

    Open an elevated command prompt window. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

    2.

    Navigate to %windir%\system32\inetsrv.

    3.

    Type appcmd.exe set config -section:system.webServer/security/authentication/windowsAuthentication -useAppPoolCredentials:true.

    "

  • We have an installation with a F5 hardware load balancer that also offloads SSL from two CRM 2011 servers on IIS 7.5 with kernel Mode Authentication enabled. SPN's for the CRM Service Account have been set on the SSL host header and the F5 machine name. All seems to work but one URL which is an ODATA REST endpoint. Traces show evidence of failing Kerberos delegation but we're stuck here.

  • Using CRM with NTLM authentication and Kernel mode authentication.  Seems when users accounts expire

    then they can no longer login.  Seems it cannot pass through a password change or expirey.  Affects Internally or external via ISA.

    Help on this would be awsome

  • Great article.  We had spn's set against the app pool account and this was breaking the app. I removed the SPN's after reading the above and this fixed it.  Thanks again!.

  • you save my life))) Thank you!

Page 2 of 2 (27 items) 12