Directory Services

DsGetDcNext

The DsGetDcNext function retrieves the next domain controller in a domain controller enumeration operation.

DWORD WINAPI DsGetDcNext(
  HANDLE GetDcContextHandle,
  PULONG SockAddressCount,
  LPSOCKET_ADDRESS* SockAddresses,
  LPTSTR* DnsHostName
);

Parameters

GetDcContextHandle
[in] Contains the domain controller enumeration context handle provided by the DsGetDcOpen function.
SockAddressCount
[out, optional] Pointer to a ULONG value that receives the number of elements in the SockAddresses array. If this parameter is NULL, socket addresses are not retreived.
SockAddresses
[out, optional] Pointer to an array of SOCKET_ADDRESS structures that receives the socket address data for the domain controller. SockAddressCount receives the number of elements in this array.

All returned addresses will be of type AF_INET or AF_INET6. The sin_port member contains the port from the server record. A port of 0 indicates no port is available from DNS.

The caller must free this memory when it is no longer required by calling LocalFree.

This parameter is ignored if SockAddressCount is NULL.

DnsHostName
[out, optional] Pointer to a string pointer that receives the DNS name of the domain controller. This parameter recevies NULL if no host name is known. The caller must free this memory when it is no longer required by calling NetApiBufferFree.

Return Values

Returns ERROR_SUCCESS if successful or a Win32 or RPC error otherwise. Possible error values include the following.
Return Code Description
ERROR_NO_MORE_ITEMS The end of the enumeration has been reached.
ERROR_FILEMARK_DETECTED The DS_NOTIFY_AFTER_SITE_RECORDS flag was specified in the OptionFlags parameter in DsGetDcOpen and the last of the site-specific domain controllers has been enumerated. DsGetDcNext will then retrieve all of the domain controllers in the domain, including the site-specific domain controllers already enumerated.

Remarks

To reset the enumeration, close the current enumeration by calling DsGetDcClose and then reopen the enumeration by calling DsGetDcOpen again.

Requirements

Client: Included in Windows XP.
Server: Included in Windows Server 2003.
Unicode: Implemented as Unicode and ANSI versions on Windows XP.
Header: Declared in Dsgetdc.h.
Library: Use Netapi32.lib.

See Also

DsGetDcOpen, DsGetDcClose, SOCKET_ADDRESS, LocalFree, NetApiBufferFree, Enumerating Domain Controllers, Directory Service Functions