Directory Services


The DsListServersForDomainInSite function lists all the servers in a domain in a site.

DWORD DsListServersForDomainInSite(
  LPTSTR domain,
  LPTSTR site,
  PDS_NAME_RESULT* ppServers


[in] Bind handle to the directory service.
[in] 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.
[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.
[out] 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 Values

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.
Return Code Description
ERROR_INVALID_PARAMETER A parameter is incorrect.
ERROR_NOT_ENOUGH_MEMORY There is insufficient memory available.


Individual name conversion errors are reported in the returned DS_NAME_RESULT structure.


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.

See Also

DsFreeNameResult, DS_NAME_RESULT, Domain Controller and Replication Management Functions