Platform SDK: Active Directory, ADSI, and 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.
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 character ('/'), which is used to separate the components of the SPN.
A program with the appropriate privileges, which is 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 will be running. Clients can then use the SPNs to authenticate the service.
Windows NT/2000: Requires Windows 2000.
Header: Declared in Ntdsapi.h.
Library: Included as a resource in Ntdsapi.dll.
Unicode: Implemented as Unicode and ANSI versions on Windows 2000.
DC and Replication Management Functions, DsFreeSpnArray, DsWriteAccountSpn