What is a SPN mapping?
A Service Principal Name (SPN) mapping allows a service running on an Active Directory computer to be associated with a domain account that are responsible for the management of the service. This allows the use of mutual Kerberos authentication, and an account defined in a SPN mapping are able to request Kerberos tickets on the requesting user`s behalf. Examples of services that uses Kerberos and SPN mappings include SQL Servers, web servers, LDAP servers, Exchange servers and so on.
Validation of SPN mappings
A SPN mapping must be unique within an Active Directory domain, and duplicate mappings will result in problems for the involved services.
While the command line tool setspn.exe, which are used for managing SPN mappings also can be used for queries, I wanted to use Windows PowerShell to accomplish this. I`ve put together a script module with two functions:
Resolve-SPN – Resolves the provided SPN mapping
Resolve-AllDuplicateDomainSPNs – Resolves all SPN mappings in the domain and reports duplicate mappings
The script module are available on the TechNet Script Center Gallery, click here for the direct link.
Save the script module as a psm1-file in the following directory: %userprofile%DocumentsWindowsPowerShellModulesSPNValidation
You need to manually create the 3 subfolders under %userprofile%Documents if they doesn`t exist.
When done, start Windows PowerShell and type the following command:
You should now see the SPNValidation module.
Import the module with the Import-Module cmdlet:
Resolve-AllDuplicateDomainSPNs can be executed without any parameters:
Resolve-SPN has one mandatory parameter: –SPN
Note that the PowerShell Active Directory module for Windows
Server 2008 R2 are required, because the Get-ADObject cmdlet are used in one of the script module`s functions.
The PowerShell Active Directory module are also available in Remote Server Administration Tools (RSAT) for Windows 7.