Directory Services |
The DsGetSpn function constructs an array of one or more service principal names (SPNs). Each name in the array identifies an instance of a service. These SPNs may be registered with the directory service (DS) using the DsWriteAccountSpn function.
DWORD DsGetSpn( DS_SPN_NAME_TYPE ServiceType, LPCTSTR ServiceClass, LPCTSTR ServiceName, USHORT InstancePort, USHORT cInstanceNames, LPCTSTR* pInstanceNames, const USHORT* pInstancePorts, DWORD* pcSpn, LPTSTR** prpszSpn );
Value | Meaning |
---|---|
DS_SPN_DNS_HOST, DS_SPN_DN_HOST, DS_SPN_NB_HOST | The SPNs have the following format.
ServiceClass/ InstanceName: InstancePort The ServiceName parameter must be NULL. This is the SPN format for a host-based service, which provides services identified with its host computer. The InstancePort component is optional. |
DS_SPN_DOMAIN, DS_SPN_NB_DOMAIN | The SPNs have the following format.
ServiceClass/ InstanceName: InstancePort/ ServiceName The ServiceName parameter must be the DNS name or DN of a domain. This format is used for a replicable service that provides services to the specified domain. |
DS_SPN_SERVICE | The SPNs have the following format.
ServiceClass/ InstanceName: InstancePort/ ServiceName The ServiceName parameter must be a canonical DN or DNS name that identifies an instance of the service. For example, it could be a DNS name of a SRV record, or the distinguished name of the service connection point for this service instance. |
If the function returns an array of SPNs, the return value is ERROR_SUCCESS.
If the function fails, the return value can be one of the following error codes.
Return Code | Description |
---|---|
ERROR_INVALID_PARAMETER | A parameter is incorrect. |
ERROR_NOT_ENOUGH_MEMORY | There is insufficient memory available. |
ERROR_DS_BAD_NAME_SYNTAX | The ServiceName parameter does not contain a valid name for a service. |
To create SPNs for multiple instances of a replicated service running on multiple host computers
To create SPNs for multiple instances of a service running on the same host computer
String parameters cannot include the forward slash (/), which is used to separate the components of the SPN.
An application with the appropriate privileges, which are usually those of a domain administrator, can call the DsWriteAccountSpn function to register one or more SPNs on the user or computer account where the service is running. Clients can then use the SPNs to authenticate the service.
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.
DsFreeSpnArray, DsWriteAccountSpn, Domain Controller and Replication Management Functions