Want to test and troubleshoot Kerberos authentication to your MOSS site?

Okay, we have configured our MOSS site so that the users are able to authenticate with Kerberos.
But how do we know for sure that Kerberos was used and the authentication has not fallen back to NTLM? Here is what we can do with the right tools.

At first, we should install a tool which allows us to have a look on the traffic between the browser and the server. The tool I prefer is called Fiddler, you can download it from here: http://www.fiddlertool.com/Fiddler2/version.asp.
Just install it on a client machine and start it. It works as a proxy between the browser and the client, so you should take a client that reaches the MOSS server without another proxy. Then just open your browser and then your MOSS site. Fiddler should log the HTTP packets and you should get something like that:
 1 - Fiddler-NTLM
In the screenshot we can see that NTLM was used and we have to find the reason why Kerberos was not used.

Very often the reason is a very simple one: duplicate SPNs.
Here is a way to export all existing SPNs of a domain:

ldifde -f c:spn_out.txt -d “DC=test,DC=local” -l serviceprincipalname -r “(serviceprincipalname=*)” -p subtree

In my test environment the Active Directory Domain was called test.local, you have to alter the command with your domain name.

Here is the output from the command:
2 - ldifde

Here is the generated text file:
3 - ldifde2

As you can see, there are a lot of SPNs, even in a very small environment. This makes troubleshooting very difficult, especially in large environments.
What can we see in the screenshot above? The problem is, that the SPNs are sorted by security principals (computers, users) and not by services. In my example I intentionally created two SPNs for my MOSS site testapp.local.

Here is the screenshot with the highlited duplicate SPNs:
3 - ldifde2

As you can see, the service HTTP/testapp.local is registered two times, for the user mossservice and the user sqlservice. When a user wants to authenticate to the MOSS site with Kerberos, he cannot know for which user he has to request a Kerberos ticket and Kerberos fails.

But there is an easier way to discover duplicate SPNs. When you are troubleshooting Kerberos authentication, you know the name of the service the user wants to connect to. In my case the MOSS site has the hostheader testapp.local and the service is HTTP/testapp.local.
Microsoft provides a script to discover duplicate SPNs. You can download the source here: http://support.microsoft.com/kb/929650. Just copy the sourcecode to a text file and rename it to SPNHelper.vbs. Then you can use this script with the following command:

cscript SPNHelper.vbs /f:duplicatespn /spn:HTTP/testapp.local

(Note that the help says the command should be cscript SPNHelper.vbs /f:duplicatespn /spn:HTTP:/testapp.local [the : after the HTTP in the SPN], but his is a typo!)

The script gives us this output:
4 - SPNhelper-Duplicate-SPN

Now we can be sure that Kerberos cannot work, because we have duplicate SPNs.
We have to delete the wrong SPN:
5 - setspn-delete

In my example, the application pool ID of the MOSS site is testmossservice, so testsqlservice was wrong.

Now we can make another authentication test with Fiddler, but at first we should delete the previously logged session for clarity:
6 - fiddler-cleanup

After we open the MOSS site another time, Fiddler states that Kerberos was used:
7 - fiddler-kerberos

That’s it!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Furl
  • LinkedIn
  • Live
  • MisterWong.DE
  • Technorati
  • De.lirio.us
  • TwitThis

Tags: ,

4 Responses to “Want to test and troubleshoot Kerberos authentication to your MOSS site?”

  1. caulkett Says:

    Hey Christian,

    Awesome post, has come in really handy.

    I wouldn’t mind some help if you don’t mind. I’m trying to use the SPN helper script but it keeps popping up a usage window. As if I’m getting the path wrong. Have you seen this before?

    Im using -
    cscript spnhelper.vbs /f:duplicatespn /spn:HTTP/intranetportal

    It is worth mentioning that I’m using Windows Server 2008.

    Thanks for your time

  2. Christian Says:

    Hi Adam,

    Windows Server 2008 has an integrated search for duplicate SPNs:

    Identify the duplicate SPN
    To identify the duplicate SPN:
    1. Log on to the computer referenced in the event log message. If this computer is not running Windows Server 2008, you must download and install the Windows Server 2003 Resource Kit, which includes setspn.exe.
    2. Click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
    3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
    4. Type setspn -X.
    5. The output of this command will show the duplicate SPNs.
    6. Use the following procedure to remove one of the duplicate SPNs.
    http://technet2.microsoft.com/windowsserver2008/en/library/39b7428a-2b45-4640-9bd7-46833007d38d1033.mspx?mfr=true

    Regards,

    Christian

  3. bookerdog Says:

    Very useful post, though I still haven’t figured out my issue yet. But I wanted to mention to anybody else that might try and use the script posted on the Microsoft site, there is a small, but very important typo in the code that they have posted.

    The first line reads:
    ‘Dim argSPN, argUser, argComputer, spnToSearch, objCategory, strFilter , searchCategory, domainInput

    Well the apostrophe in VB is how you comment out a line, so all of these variable declarations are commented out.

    Delete the first apostrophe, resave the script, and it will work as advertised.

  4. Emmanuel ISSALY Says:

    Nice post, but the pictures look broken on my side.

Leave a Reply