Directory Services |
The DsMakeSpn function constructs a service principal name (SPN) that identifies a service instance.
A client application uses this function to compose an SPN, which it uses to authenticate the service instance. For example, the client can pass an SPN in the pszTargetName parameter of the InitializeSecurityContext function.
DWORD DsMakeSpn( LPCTSTR ServiceClass, LPCTSTR ServiceName, LPCTSTR InstanceName, USHORT InstancePort, LPCTSTR Referrer, DWORD* pcSpnLength, LPTSTR pszSpn );
For more information about how the ServiceName, InstanceName and InstancePort parameters are used to compose an SPN, see the following Remarks section.
If ServiceName specifies the DNS or NetBIOS name of the service host computer, the InstanceName parameter must be NULL.
If ServiceName specifies a DNS domain name, the name of a DNS SRV record, or a distinguished name, such as the DN of a service connection point, the InstanceName parameter must specify the DNS or NetBIOS name of the service host computer.
The pcSpnLength parameter also receives the actual length of the SPN created, including the terminating null character.
Return Code | Description |
---|---|
ERROR_BUFFER_OVERFLOW | The buffer in pszSpn is not large enough to hold the constructed SPN. The required length for the buffer is returned in pcSpnLength. |
ERROR_INVALID_PARAMETER | A parameter is incorrect. |
The format of the SPN produced by the DsMakeSpn function depends on the input parameters. There are two basic formats. Both formats begin with the ServiceClass string followed by a host computer name and an optional InstancePort component.
To produce an SPN with the ServiceClass/host format
Note This format is used by host-based services.
ServiceClass/host: InstancePort/Referrer
To produce an SPN with the ServiceClass/host: InstancePort format
Note This format is used by replicable services.
ServiceClass/host: InstancePort/ServiceName
The Referrer parameter is used only if the ServiceName parameter specifies the IP address of the service's host computer. In this case, Referrer specifies the DNS name of the computer that gave the IP address as a referral. The SPN has the following format:
ServiceClass/host: InstancePort/Referrer
where the host component is the InstanceName string or the ServiceName string if InstanceName is NULL, and the InstancePort component is optional.
String parameters cannot include the forward slash (/) character, as it is used to separate the components of the SPN.
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Unicode: Implemented as Unicode and ANSI versions on Windows
NT/2000/XP.
Header: Declared in Ntdsapi.h.
Library: Use Ntdsapi.lib.
InitializeSecurityContext, Domain Controller and Replication Management Functions