### DS_SPN_DOMAIN SPN format example Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN format for DS_SPN_DOMAIN, which identifies a replicable service that provides services to the specified domain. ```cpp fabrikam.com ``` -------------------------------- ### DS_SPN_NB_DOMAIN SPN format example Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN format for DS_SPN_NB_DOMAIN, which identifies a replicable service that provides services to the specified NetBIOS domain. ```cpp fabrikam ``` -------------------------------- ### DS_SPN_NB_HOST SPN format example Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN format for DS_SPN_NB_HOST, which identifies a host-based service using the NetBIOS name of the host computer. ```cpp jeffsmith-nec ``` -------------------------------- ### DS_SPN_DN_HOST SPN format example Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN format for DS_SPN_DN_HOST, which identifies a host-based service using the distinguished name of the host computer. ```cpp cn=jeffsmith,ou=computers,dc=fabrikam,dc=com ``` -------------------------------- ### DS_SPN_DNS_HOST SPN format example Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN format for DS_SPN_DNS_HOST, which identifies a host-based service using its host computer's distinguished name service. ```cpp jeffsmith.fabrikam.com ``` -------------------------------- ### DS_SPN_SERVICE SPN format examples Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_spn_name_type Example SPN formats for DS_SPN_SERVICE, which identifies a specified service. The format varies depending on the service type, including RPC services, Winsock services, and other services. ```cpp cn=anRpcService,cn=RPC Services,cn=system,dc=fabrikam,dc=com ``` ```cpp cn=aWsService,cn=Winsock Services,cn=system,dc=fabrikam,dc=com ``` ```cpp cn=aService,dc=itg,dc=fabrikam,dc=com ``` ```cpp www.fabrikam.com, ftp.fabrikam.com, ldap.fabrikam.com ``` ```cpp products.fabrikam.com ``` -------------------------------- ### DS_REPSYNCALL_SYNCW structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_repsyncall_syncw Defines the DS_REPSYNCALL_SYNCW structure used by DsReplicaSyncAll to identify a single replication operation between a source and destination server. The members pszSrcId and pszDstId are pointers to null-terminated strings specifying the DNS GUIDs of the source and destination servers, respectively. The pszNC member is a pointer to a null-terminated string, and pguidSrc and pguidDst are pointers to GUID structures. ```C++ typedef struct { LPWSTR pszSrcId; LPWSTR pszDstId; LPWSTR pszNC; GUID *pguidSrc; GUID *pguidDst; } DS_REPSYNCALL_SYNCW, *PDS_REPSYNCALL_SYNCW; ``` -------------------------------- ### DsQuerySitesByCostW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsquerysitesbycostw The DsQuerySitesByCostW function gets the communication cost between one site and one or more other sites. It takes a directory service handle, the source site, an array of destination sites, and returns an array of DS_SITE_COST_INFO structures containing the cost data. ```APIDOC ## DsQuerySitesByCostW ### Description Gets the communication cost between one site and one or more other sites. ### Syntax ```c NTDSAPI_POSTXP DWORD DsQuerySitesByCostW( [in] HANDLE hDS, [in] LPWSTR pwszFromSite, [in] LPWSTR *rgwszToSites, [in] DWORD cToSites, [in] DWORD dwFlags, [out] PDS_SITE_COST_INFO *prgSiteInfo ); ``` ### Parameters - **hDS** (HANDLE) - Required - A directory service handle. - **pwszFromSite** (LPWSTR) - Required - Pointer to a null-terminated string that contains the relative distinguished name of the site the costs are measured from. - **rgwszToSites** (LPWSTR*) - Required - Contains an array of null-terminated string pointers that contain the relative distinguished names of the sites the costs are measured to. - **cToSites** (DWORD) - Required - Contains the number of elements in the _rgwszToSites_ array. - **dwFlags** (DWORD) - Required - Reserved. - **prgSiteInfo** (PDS_SITE_COST_INFO*) - Required - Pointer to an array of DS_SITE_COST_INFO structures that receives the cost data. Each element in this array contains the cost data between the site identified by the _pwszFromSite_ parameter and the site identified by the corresponding _rgwszToSites_ element. The caller must free this memory when it is no longer required by calling DsQuerySitesFree. ### Return Value Returns **ERROR_SUCCESS** if successful or a Win32 or RPC error code otherwise. Possible error codes include values listed in the following list. ### Remarks The cost values obtained by this function are only used to compare and have no meaning by themselves. For example, the cost for site 1 can be compared to the cost for site 2, but the cost for site 1 cannot be compared to a fixed value. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_SITE_COST_INFO - Domain Controller and Replication Management Functions - DsQuerySitesFree ``` -------------------------------- ### DsQuerySitesByCostA Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsquerysitesbycosta The DsQuerySitesByCostA function gets the communication cost between one site and one or more other sites. It takes a directory service handle, the source site, an array of destination sites, and returns an array of DS_SITE_COST_INFO structures containing the cost data. ```APIDOC ## DsQuerySitesByCostA ### Description Gets the communication cost between one site and one or more other sites. ### Syntax ```c NTDSAPI_POSTXP DWORD DsQuerySitesByCostA( [in] HANDLE hDS, LPSTR pszFromSite, LPSTR *rgszToSites, [in] DWORD cToSites, [in] DWORD dwFlags, [out] PDS_SITE_COST_INFO *prgSiteInfo ); ``` ### Parameters - **hDS** (HANDLE) - Required - A directory service handle. - **pszFromSite** (LPSTR) - Required - Pointer to a null-terminated string that contains the relative distinguished name of the site the costs are measured from. - **rgszToSites** (LPSTR*) - Required - Contains an array of null-terminated string pointers that contain the relative distinguished names of the sites the costs are measured to. - **cToSites** (DWORD) - Required - Contains the number of elements in the _rgwszToSites_ array. - **dwFlags** (DWORD) - Required - Reserved. - **prgSiteInfo** (PDS_SITE_COST_INFO*) - Required - Pointer to an array of DS_SITE_COST_INFO structures that receives the cost data. Each element in this array contains the cost data between the site identified by the _pwszFromSite_ parameter and the site identified by the corresponding _rgwszToSites_ element. The caller must free this memory when it is no longer required by calling DsQuerySitesFree. ### Return Value Returns **ERROR_SUCCESS** if successful or a Win32 or RPC error code otherwise. Possible error codes include values listed in the following list. ### Remarks The cost values obtained by this function are only used to compare and have no meaning by themselves. For example, the cost for site 1 can be compared to the cost for site 2, but the cost for site 1 cannot be compared to a fixed value. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_SITE_COST_INFO - Domain Controller and Replication Management Functions - DsQuerySitesFree ``` -------------------------------- ### DsListInfoForServerA Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistinfoforservera Lists miscellaneous data for a server. ```APIDOC ## DsListInfoForServerA ### Description Lists miscellaneous data for a server. ### Syntax ```c NTDSAPI DWORD DsListInfoForServerA( [in] HANDLE hDs, [in] LPCSTR server, [out] PDS_NAME_RESULTA *ppInfo ); ``` ### Parameters - **hDs** (HANDLE) - Required - A directory service handle obtained from either the DSBind or DSBindWithCred function. - **server** (LPCSTR) - Required - Pointer to a null-terminated string that specifies the server name. This name must be the same as one of the strings returned by the DsListServersForDomainInSite or DsListServersInSite function. - **ppInfo** (PDS_NAME_RESULTA*) - Required - Pointer to a variable that receives a pointer to a DS_NAME_RESULT structure that contains the server data. The returned structure must be deallocated using DsFreeNameResult. ### Return Value If the function returns server data, the return value is **NO_ERROR**. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### DsListServersForDomainInSiteW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistserversfordomaininsitew Lists all the servers in a domain in a site. ```APIDOC ## DsListServersForDomainInSiteW ### Description Lists all the servers in a domain in a site. ### Syntax ```c NTDSAPI DWORD DsListServersForDomainInSiteW( [in] HANDLE hDs, [in] LPCWSTR domain, [in] LPCWSTR site, [out] PDS_NAME_RESULTW *ppServers ); ``` ### Parameters - `hDs` (HANDLE) - Required - Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - `domain` (LPCWSTR) - Required - Pointer to a null-terminated string that specifies the domain name. This string must be the same as one of the strings returned by DsListDomainsInSite function. - `site` (LPCWSTR) - Required - Pointer to a null-terminated string that specifies the site name. This string is taken from the list of site names returned by the DsListSites function. - `ppServers` (PDS_NAME_RESULTW*) - Required - Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of servers in the domain. The returned structure must be freed using the DsFreeNameResult function. ### Return Value If the function returns a list of servers, the return value is **NO_ERROR**. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### Simplified SPN format (syntax) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsclientmakespnfortargetserverw Shows the format of the SPN constructed by DsClientMakeSpnForTargetServer. The instance name portion (second position) is always set to default, and the port and referrer fields are not used. ```text ServiceClass / ServiceName / ServiceName ``` -------------------------------- ### DsListServersInSiteA Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistserversinsitea Lists all the servers in a site. ```APIDOC ## [DsListServersInSiteA] (ntdsapi.h) ### Description Lists all the servers in a site. ### Method Function call ### Endpoint DsListServersInSiteA ### Parameters #### Input Parameters - **hDs** (HANDLE) - Required - A directory service handle obtained from either the DSBind or DSBindWithCred function. - **site** (LPCSTR) - Required - Pointer to a null-terminated string that specifies the site name. The site name uses a distinguished name format. It is taken from the list of sites returned by the DsListSites function. - **ppServers** (PDS_NAME_RESULTA*) - Required - Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of servers in the site. The returned structure must be freed using the DsFreeNameResult function. ### Return Value If the function returns a list of servers, the return value is NO_ERROR. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### DsMapSchemaGuidsW function signature Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsmapschemaguidsw The syntax for the DsMapSchemaGuidsW function, which converts GUIDs of directory service schema objects to display names. It takes a directory service handle, a count of GUIDs, an array of GUIDs, and a pointer to receive an array of DS_SCHEMA_GUID_MAP structures. The returned array must be deallocated with DsFreeSchemaGuidMap. ```cpp NTDSAPI DWORD DsMapSchemaGuidsW( [in] HANDLE hDs, [in] DWORD cGuids, [in] GUID *rGuids, [out] DS_SCHEMA_GUID_MAPW **ppGuidMap ); ``` -------------------------------- ### DsGetDomainControllerInfoA function syntax (C++) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsgetdomaincontrollerinfoa Declares the DsGetDomainControllerInfoA function, which retrieves domain controller information. The hDs parameter must be a directory service handle from DSBind or DSBindWithCred. The InfoLevel parameter determines the structure version (1, 2, or 3). The caller must free the returned array with DsFreeDomainControllerInfo. ```cpp NTDSAPI DWORD DsGetDomainControllerInfoA( [in] HANDLE hDs, [in] LPCSTR DomainName, [in] DWORD InfoLevel, [out] DWORD *pcOut, [out] VOID **ppInfo ); ``` -------------------------------- ### DsBindWithCredA function syntax (C++) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsbindwithcreda Declarations of the DsBindWithCredA function signature, showing parameters for the domain controller name, DNS domain name, auth identity handle, and output binding handle. Return type is DWORD. ```cpp NTTSAPI DWORD DsBindWithCredA( [in, optional] LPCSTR DomainControllerName, [in, optional] LPCSTR DnsDomainName, [in, optional] RPC_AUTH_IDENTITY_HANDLE AuthIdentity, [out] HANDLE *phDS ); ``` -------------------------------- ### DsClientMakeSpnForTargetServerW function syntax (C++) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsclientmakespnfortargetserverw C++ declaration of the DsClientMakeSpnForTargetServerW function. The function constructs an SPN for a target server. The ServiceName parameter should be a DNS host name; using an IP address is not recommended due to potential DNS spoofing. The pcSpnLength parameter is in/out and receives the number of characters copied, including the terminating NULL. ```cpp NTDSAPI DWORD DsClientMakeSpnForTargetServerW( [in] LPCWSTR ServiceClass, [in] LPCWSTR ServiceName, [in, out] DWORD *pcSpnLength, [out] LPWSTR pszSpn ); ``` -------------------------------- ### DsMapSchemaGuidsA Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsmapschemaguidsa Converts GUIDs of directory service schema objects to their display names. ```APIDOC ## DsMapSchemaGuidsA ### Description Converts GUIDs of directory service schema objects to their display names. ### Syntax ```c NTDSAPI DWORD DsMapSchemaGuidsA( [in] HANDLE hDs, [in] DWORD cGuids, [in] GUID *rGuids, [out] DS_SCHEMA_GUID_MAPA **ppGuidMap ); ``` ### Parameters #### hDs - **Type**: HANDLE - **Direction**: [in] - **Description**: Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. #### cGuids - **Type**: DWORD - **Direction**: [in] - **Description**: Indicates the number of elements in _rGuids_. #### rGuids - **Type**: GUID* - **Direction**: [in] - **Description**: Pointer to an array of **GUID** values for the objects to be mapped. #### ppGuidMap - **Type**: DS_SCHEMA_GUID_MAPA** - **Direction**: [out] - **Description**: Pointer to a variable that receives a pointer to an array of DS_SCHEMA_GUID_MAP structures that contain the display names of the objects in _rGuids_. This array must be deallocated using DsFreeSchemaGuidMap. ### Return Value Returns a standard error code that includes the following values. ### Remarks The ntdsapi.h header defines DsMapSchemaGuids as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_SCHEMA_GUID_MAP - Domain Controller and Replication Management Functions - DsFreeSchemaGuidMap ``` -------------------------------- ### DsListServersInSiteW function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistserversinsitew The function signature for DsListServersInSiteW as defined in ntdsapi.h. ```cpp NTDSAPI DWORD DsListServersInSiteW( [in] HANDLE hDs, [in] LPCWSTR site, [out] PDS_NAME_RESULTW *ppServers ); ``` -------------------------------- ### DsListInfoForServerW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistinfoforserverw Documentation for the DsListInfoForServerW function, which lists miscellaneous data for a server. ```APIDOC ## [Function] DsListInfoForServerW ### Description Lists miscellaneous data for a server. ### Syntax ```c NTDSAPI DWORD DsListInfoForServerW( [in] HANDLE hDs, [in] LPCWSTR server, [out] PDS_NAME_RESULTW *ppInfo ); ``` ### Parameters - **hDs** (HANDLE) - [in] - A directory service handle obtained from either the DSBind or DSBindWithCred function. - **server** (LPCWSTR) - [in] - Pointer to a null-terminated string that specifies the server name. This name must be the same as one of the strings returned by the DsListServersForDomainInSite or DsListServersInSite function. - **ppInfo** (PDS_NAME_RESULTW*) - [out] - Pointer to a variable that receives a pointer to a DS_NAME_RESULT structure that contains the server data. The returned structure must be deallocated using DsFreeNameResult. ### Return Value If the function returns server data, the return value is **NO_ERROR**. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### DsMapSchemaGuidsA function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsmapschemaguidsa The function signature for mapping schema GUIDs to display names in C++. ```C++ NTDSAPI DWORD DsMapSchemaGuidsA( [in] HANDLE hDs, [in] DWORD cGuids, [in] GUID *rGuids, [out] DS_SCHEMA_GUID_MAPA **ppGuidMap ); ``` -------------------------------- ### DsBindByInstanceW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsbindbyinstancew Explicitly binds to any AD LDS or Active Directory instance. ```APIDOC ## DsBindByInstanceW ### Description Explicitly binds to any AD LDS or Active Directory instance. ### Syntax ```c NTDSAPI_POSTXP DWORD DsBindByInstanceW( [in] LPCWSTR ServerName, [in] LPCWSTR Annotation, [in] GUID *InstanceGuid, [in] LPCWSTR DnsDomainName, [in, optional] RPC_AUTH_IDENTITY_HANDLE AuthIdentity, [in, optional] LPCWSTR ServicePrincipalName, [in, optional] DWORD BindFlags, [out] HANDLE *phDS ); ``` ### Parameters - **ServerName** (LPCWSTR) - Required - Pointer to a null-terminated string that specifies the name of the instance. Required to bind to an AD LDS instance. If NULL when binding to an Active Directory instance, the DnsDomainName parameter must contain a value. If both ServerName and DnsDomainName are NULL, the function fails with ERROR_INVALID_PARAMETER (87). - **Annotation** (LPCWSTR) - Required - Pointer to a null-terminated string that specifies the port number of the AD LDS instance or NULL when binding to an Active Directory instance. For example, "389". If NULL when binding by domain to an Active Directory instance, DnsDomainName must be specified. If NULL when binding to an AD LDS instance, InstanceGuid must be specified. - **InstanceGuid** (GUID*) - Required - Pointer to a GUID value that contains the GUID of the AD LDS instance. The GUID value is the objectGUID property of the nTDSDSA object of the instance. If NULL when binding to an AD LDS instance, Annotation must be specified. - **DnsDomainName** (LPCWSTR) - Required - Pointer to a null-terminated string that specifies the DNS name of the domain when binding to an Active Directory instance by domain. Set to NULL to bind to an Active Directory instance by server or to an AD LDS instance. - **AuthIdentity** (RPC_AUTH_IDENTITY_HANDLE) - Optional - Handle to the credentials used to start the RPC session. Use the DsMakePasswordCredentials function to create a structure suitable for AuthIdentity. - **ServicePrincipalName** (LPCWSTR) - Optional - Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL is equivalent to a call to the DsBindWithCred function. - **BindFlags** (DWORD) - Optional - Contains a set of flags that define the behavior of this function. Can contain zero or a combination of one or more of the following values: - **NTDSAPI_BIND_ALLOW_DELEGATION (1)** - Causes the bind to use the delegate impersonation level. This enables operations that require delegation, such as DsAddSidHistory, to succeed. Specifying this flag also causes DsBindWithSpnEx to operate similar to DsBindWithSpn. If not specified, the bind will use the impersonate impersonation level. Most operations do not require the delegate impersonation level; this flag should only be specified if required. Binding to a rogue server with the delegate impersonation level enables the rogue server to connect to a non-rogue server with your credentials and perform unintended operations. - **NTDSAPI_BIND_FORCE_KERBEROS (4)** - Active Directory Lightweight Directory Services: If specified, DsBindWithSpnEx requires Kerberos authentication to be used. If Kerberos authentication cannot be established, DsBindWithSpnEx will not attempt to authenticate with any other mechanism. - **phDS** (HANDLE*) - Required - Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. ### Return Value DWORD - The return value is not explicitly documented in the source. Typically, a success code (e.g., ERROR_SUCCESS) is returned on success, and a failure code on error. ### Remarks This function is the Unicode version of DsBindByInstance. The function explicitly binds to any AD LDS or Active Directory instance. ``` -------------------------------- ### DsMapSchemaGuidsW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsmapschemaguidsw The DsMapSchemaGuids function converts GUIDs of directory service schema objects to their display names. ```APIDOC ## DsMapSchemaGuidsW ### Description Converts GUIDs of directory service schema objects to their display names. ### Syntax ```c NTDSAPI DWORD DsMapSchemaGuidsW( [in] HANDLE hDs, [in] DWORD cGuids, [in] GUID *rGuids, [out] DS_SCHEMA_GUID_MAPW **ppGuidMap ); ``` ### Parameters - **hDs** (HANDLE) - Required - Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - **cGuids** (DWORD) - Required - Indicates the number of elements in rGuids. - **rGuids** (GUID*) - Required - Pointer to an array of GUID values for the objects to be mapped. - **ppGuidMap** (DS_SCHEMA_GUID_MAPW**) - Required - Pointer to a variable that receives a pointer to an array of DS_SCHEMA_GUID_MAP structures that contain the display names of the objects in rGuids. This array must be deallocated using DsFreeSchemaGuidMap. ### Return Value Returns a standard error code that includes the following values. ### Remarks The ntdsapi.h header defines DsMapSchemaGuids as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_SCHEMA_GUID_MAP - Domain Controller and Replication Management Functions - DsFreeSchemaGuidMap ``` -------------------------------- ### DsListServersInSiteW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistserversinsitew Lists all servers in a specified site. The function takes a directory service handle, a site name, and a pointer to receive a DS_NAME_RESULT structure containing the server list. ```APIDOC ## DsListServersInSiteW ### Description Lists all servers in a specified site. ### Syntax ```c NTDSAPI DWORD DsListServersInSiteW( [in] HANDLE hDs, [in] LPCWSTR site, [out] PDS_NAME_RESULTW *ppServers ); ``` ### Parameters - **hDs** (HANDLE) - [in] A directory service handle obtained from either the DSBind or DSBindWithCred function. - **site** (LPCWSTR) - [in] Pointer to a null-terminated string that specifies the site name. The site name uses a distinguished name format. It is taken from the list of sites returned by the DsListSites function. - **ppServers** (PDS_NAME_RESULTW*) - [out] Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of servers in the site. The returned structure must be freed using the DsFreeNameResult function. ### Return Value If the function returns a list of servers, the return value is **NO_ERROR**. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### DS_SCHEMA_GUID_MAPW structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_schema_guid_mapw The C++ structure definition for DS_SCHEMA_GUID_MAPW, which includes the GUID, its type, and a pointer to the display name. ```C++ typedef struct { GUID guid; DWORD guidType; #if ... WCHAR *pName; #else LPWSTR pName; #endif } DS_SCHEMA_GUID_MAPW, *PDS_SCHEMA_GUID_MAPW; ``` -------------------------------- ### DS_REPL_OPW structure definition (C++) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_repl_opw Defines the DS_REPL_OPW structure in C++. Use this structure to represent a replication task returned by DsReplicaGetInfo or DsReplicaGetInfo2. The ulOptions member contains flags that depend on the OpType member, with values such as DS_REPSYNC_*, DS_REPADD_*, DS_REPDEL_*, DS_REPMOD_*, and DS_REPSUPD_*. ```cpp typedef struct _DS_REPL_OPW { FILETIME ftimeEnqueued; ULONG ulSerialNumber; ULONG ulPriority; DS_REPL_OP_TYPE OpType; ULONG ulOptions; LPWSTR pszNamingContext; LPWSTR pszDsaDN; LPWSTR pszDsaAddress; UUID uuidNamingContextObjGuid; UUID uuidDsaObjGuid; } DS_REPL_OPW; ``` -------------------------------- ### DS_REPSYNCALL_SYNCA structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_repsyncall_synca The C++ structure definition for DS_REPSYNCALL_SYNCA, which contains pointers to server identifiers and GUIDs for replication. ```C++ typedef struct { LPSTR pszSrcId; LPSTR pszDstId; LPSTR pszNC; GUID *pguidSrc; GUID *pguidDst; } DS_REPSYNCALL_SYNCA, *PDS_REPSYNCALL_SYNCA; ``` -------------------------------- ### DsClientMakeSpnForTargetServerA function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsclientmakespnfortargetservera The function signature for the ANSI version of DsClientMakeSpnForTargetServer. ```C++ NTDSAPI DWORD DsClientMakeSpnForTargetServerA( [in] LPCSTR ServiceClass, [in] LPCSTR ServiceName, [in, out] DWORD *pcSpnLength, [out] LPSTR pszSpn ); ``` -------------------------------- ### DsFreeSchemaGuidMapA Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsfreeschemaguidmapa Frees memory allocated by DsMapSchemaGuids for a DS_SCHEMA_GUID_MAP structure. This function is part of the NTDS API and is used to clean up resources after mapping schema GUIDs. ```APIDOC ## DsFreeSchemaGuidMapA ### Description Frees memory that the DsMapSchemaGuids function has allocated for a DS_SCHEMA_GUID_MAP structure. ### Syntax ```c NTDSAPI VOID DsFreeSchemaGuidMapA( [in] PDS_SCHEMA_GUID_MAPA pGuidMap ); ``` ### Parameters - **pGuidMap** (PDS_SCHEMA_GUID_MAPA) - Required - Pointer to a DS_SCHEMA_GUID_MAP structure to deallocate. ### Return Value This function does not return a value. ### Remarks The ntdsapi.h header defines DsFreeSchemaGuidMap as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ``` -------------------------------- ### DsBindWithSpnExW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsbindwithspnexw Binds to a domain using the specified credentials and Service Principal Name, with optional flags to control binding behavior. ```APIDOC ## DsBindWithSpnExW ### Description Binds to a domain using the specified credentials and Service Principal Name, with optional flags to control binding behavior. ### Syntax ```cpp NTDSAPI_POSTXP DWORD DsBindWithSpnExW( [in, optional] LPCWSTR DomainControllerName, [in, optional] LPCWSTR DnsDomainName, [in, optional] RPC_AUTH_IDENTITY_HANDLE AuthIdentity, [in, optional] LPCWSTR ServicePrincipalName, [in, optional] DWORD BindFlags, [out] HANDLE *phDS ); ``` ### Parameters - **DomainControllerName** (LPCWSTR) - Optional - Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. - **DnsDomainName** (LPCWSTR) - Optional - Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. - **AuthIdentity** (RPC_AUTH_IDENTITY_HANDLE) - Optional - Credentials to be used for the bind. If NULL, the credentials of the calling thread are used. - **ServicePrincipalName** (LPCWSTR) - Optional - Service Principal Name to assign to the client. Passing NULL is equivalent to a call to DsBindWithCred. - **BindFlags** (DWORD) - Optional - Flags that define the behavior of this function. Can be zero or a combination of the following values: - **NTDSAPI_BIND_ALLOW_DELEGATION (1)** - Uses the delegate impersonation level, allowing operations that require delegation to succeed. - **NTDSAPI_BIND_FIND_BINDING (2)** - Reserved. - **NTDSAPI_BIND_FORCE_KERBEROS (4)** - Forces Kerberos authentication to be used. - **phDS** (HANDLE*) - Required - Address of a HANDLE value that receives the binding handle. Close with DsUnBind. ### Return Value A DWORD indicating success or failure. See the original documentation for error codes. ### Remarks If the NTDSAPI_BIND_ALLOW_DELEGATION flag is not specified, the bind uses the impersonate impersonation level. Most operations do not require delegation, so this flag should only be specified if absolutely required. ``` -------------------------------- ### DS_SCHEMA_GUID_MAPA structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_schema_guid_mapa C++ syntax for the DS_SCHEMA_GUID_MAPA structure. The guidType member can be one of DS_SCHEMA_GUID_ATTR, DS_SCHEMA_GUID_ATTR_SET, DS_SCHEMA_GUID_CLASS, DS_SCHEMA_GUID_CONTROL_RIGHT, or DS_SCHEMA_GUID_NOT_FOUND. The pName member may be NULL if DsMapSchemaGuids could not map the GUID to a display name. ```cpp typedef struct { GUID guid; DWORD guidType; #if ... CHAR *pName; #else LPSTR pName; #endif } DS_SCHEMA_GUID_MAPA, *PDS_SCHEMA_GUID_MAPA; ``` -------------------------------- ### DsListDomainsInSiteW function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistdomainsinsitew The function signature for DsListDomainsInSiteW as defined in ntdsapi.h. ```C++ NTDSAPI DWORD DsListDomainsInSiteW( [in] HANDLE hDs, [in] LPCWSTR site, [out] PDS_NAME_RESULTW *ppDomains ); ``` -------------------------------- ### DsReplicaGetInfo2W function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsreplicagetinfo2w C++ function signature for DsReplicaGetInfo2W, a Unicode variant that retrieves replication state data with support for paging when more than 1000 entries exist. The call takes a directory service handle, an info type, optional object and attribute identifiers, flags, enumeration context, and outputs a pointer to the requested information. ```cpp NTDSAPI DWORD DsReplicaGetInfo2W( [in] HANDLE hDS, [in] DS_REPL_INFO_TYPE InfoType, [in, optional] LPCWSTR pszObject, [in, optional] UUID *puuidForSourceDsaObjGuid, [in, optional] LPCWSTR pszAttributeName, [in, optional] LPCWSTR pszValue, [in] DWORD dwFlags, [in] DWORD dwEnumerationContext, [out] VOID **ppInfo ); ``` -------------------------------- ### DsListDomainsInSiteW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistdomainsinsitew The DsListDomainsInSiteW function lists all the domains in a site. It takes a directory service handle, a site name, and returns a pointer to a DS_NAME_RESULT structure containing the list of domains. ```APIDOC ## DsListDomainsInSiteW ### Description The **DsListDomainsInSite** function lists all the domains in a site. ### Syntax ```c NTDSAPI DWORD DsListDomainsInSiteW( [in] HANDLE hDs, [in] LPCWSTR site, [out] PDS_NAME_RESULTW *ppDomains ); ``` ### Parameters - **hDs** (HANDLE) - [in] - Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - **site** (LPCWSTR) - [in] - Pointer to a null-terminated string that specifies the site name. This string is taken from the list of site names returned by the DsListSites function. - **ppDomains** (PDS_NAME_RESULTW*) - [out] - Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of domains in the site. To free the returned structure, call the DsFreeNameResult function. ### Return Value If the function returns a list of domains, the return value is **NO_ERROR**. If the function fails, the return value can be one of the following error codes. ### Remarks Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ### See Also - DS_NAME_RESULT - Domain Controller and Replication Management Functions - DsFreeNameResult ``` -------------------------------- ### DS_REPSYNCALL_EVENT enumeration definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ne-ntdsapi-ds_repsyncall_event Defines the DS_REPSYNCALL_EVENT enumeration used with the DS_REPSYNCALL_UPDATE structure to specify the type of event. The constants range from 0 to 3, representing error, sync started, sync completed, and finished events. The callback return value is ignored for the FINISHED event. ```cpp typedef enum { DS_REPSYNCALL_EVENT_ERROR = 0, DS_REPSYNCALL_EVENT_SYNC_STARTED = 1, DS_REPSYNCALL_EVENT_SYNC_COMPLETED = 2, DS_REPSYNCALL_EVENT_FINISHED = 3 } DS_REPSYNCALL_EVENT; ``` -------------------------------- ### DS_REPL_KCC_DSA_FAILUREW structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_repl_kcc_dsa_failurew C++ typedef for the DS_REPL_KCC_DSA_FAILUREW structure. It contains fields for the DSA distinguished name, object GUID, first failure time, failure count, and last error result. The ftimeFirstFailure member's meaning depends on the InfoType parameter passed to DsReplicaGetInfo or DsReplicaGetInfo2. ```cpp typedef struct _DS_REPL_KCC_DSA_FAILUREW { LPWSTR pszDsaDN; UUID uuidDsaObjGuid; FILETIME ftimeFirstFailure; DWORD cNumFailures; DWORD dwLastResult; } DS_REPL_KCC_DSA_FAILUREW; ``` -------------------------------- ### DsListInfoForServerA function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistinfoforservera The function signature for DsListInfoForServerA as defined in ntdsapi.h. ```C++ NTDSAPI DWORD DsListInfoForServerA( [in] HANDLE hDs, [in] LPCSTR server, [out] PDS_NAME_RESULTA *ppInfo ); ``` -------------------------------- ### DS_REPL_KCC_DSA_FAILUREW_BLOB structure definition (C++) Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_repl_kcc_dsa_failurew_blob C++ typedef for the DS_REPL_KCC_DSA_FAILUREW_BLOB structure. Contains fields for the offset to the DSA DN string, the DSA object GUID, the first failure time, the number of consecutive failures, and the last error result. Used with LDAP API functions when obtaining binary data for the msDS-ReplConnectionFailures or msDS-ReplLinkFailures attribute. ```cpp typedef struct _DS_REPL_KCC_DSA_FAILUREW_BLOB { DWORD oszDsaDN; UUID uuidDsaObjGuid; FILETIME ftimeFirstFailure; DWORD cNumFailures; DWORD dwLastResult; } DS_REPL_KCC_DSA_FAILUREW_BLOB; ``` -------------------------------- ### DsListDomainsInSiteA function signature Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dslistdomainsinsitea Declares the ANSI version of DsListDomainsInSite, which lists all domains in a site. The hDs parameter must be a directory service handle from DSBind or DSBindWithCred, and site must be a site name from DsListSites. The returned DS_NAME_RESULT structure must be freed with DsFreeNameResult. ```cpp NTDSAPI DWORD DsListDomainsInSiteA( [in] HANDLE hDs, [in] LPCSTR site, [out] PDS_NAME_RESULTA *ppDomains ); ``` -------------------------------- ### DsBindW function syntax Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsbindw The C++ syntax for the DsBindW function. It binds to a domain controller using default process credentials. The function takes optional domain controller and DNS domain names and returns a handle to the binding. Use DsUnBind to close the handle. ```cpp NTDSAPI DWORD DsBindW( [in, optional] LPCWSTR DomainControllerName, [in, optional] LPCWSTR DnsDomainName, [out] HANDLE *phDS ); ``` -------------------------------- ### DS_DOMAIN_CONTROLLER_INFO_2A structure definition Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/ns-ntdsapi-ds_domain_controller_info_2a Structure returned by DsGetDomainControllerInfo. Contains domain controller data including NetBIOS name, DNS host name, site and object names, Boolean flags for PDC, enabled, and global catalog status, and GUIDs for site, computer, server, and NTDS DSA objects. The ntdsapi.h header defines DS_DOMAIN_CONTROLLER_INFO_2 as an alias that selects the ANSI or Unicode version based on the UNICODE preprocessor constant. ```cpp typedef struct { #if ... CHAR *NetbiosName; #if ... CHAR *DnsHostName; #if ... CHAR *SiteName; #if ... CHAR *SiteObjectName; #if ... CHAR *ComputerObjectName; #if ... CHAR *ServerObjectName; #if ... CHAR *NtdsDsaObjectName; #else LPSTR NetbiosName; #endif #else LPSTR DnsHostName; #endif #else LPSTR SiteName; #endif #else LPSTR SiteObjectName; #endif #else LPSTR ComputerObjectName; #endif #else LPSTR ServerObjectName; #endif #else LPSTR NtdsDsaObjectName; #endif BOOL fIsPdc; BOOL fDsEnabled; BOOL fIsGc; GUID SiteObjectGuid; GUID ComputerObjectGuid; GUID ServerObjectGuid; GUID NtdsDsaObjectGuid; } DS_DOMAIN_CONTROLLER_INFO_2A, *PDS_DOMAIN_CONTROLLER_INFO_2A; ``` -------------------------------- ### DsBindToISTGW Source: https://learn.microsoft.com/en-us/windows/win32/api/ntdsapi/nf-ntdsapi-dsbindtoistgw Documentation for the DsBindToISTGW function, which binds to the Inter-Site Topology Generator (ISTG) role holder in the domain of the local computer. ```APIDOC ## DsBindToISTGW ### Description Binds to the computer that holds the Inter-Site Topology Generator (ISTG) role in the domain of the local computer. ### Syntax ```cpp NTDSAPI_POSTXP DWORD DsBindToISTGW( [in, optional] LPCWSTR SiteName, [out] HANDLE *phDS ); ``` ### Parameters - **SiteName** (LPCWSTR) - Optional - Pointer to a null-terminated string that contains the site name used when binding. If this parameter is NULL, the site of the nearest domain controller is used. - **phDS** (HANDLE*) - Required - Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. ### Return Value Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. The following are possible error codes. ### Remarks The ntdsapi.h header defines DsBindToISTG as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. ### Requirements - **Minimum supported client**: Windows Vista - **Minimum supported server**: Windows Server 2008 - **Target Platform**: Windows - **Header**: ntdsapi.h - **Library**: Ntdsapi.lib - **DLL**: Ntdsapi.dll ```