NetGetDCName

The NetGetDCName function returns the name of the Primary Domain Controller (PDC) for the specified domain.

Security Requirements

No special group membership is required to successfully execute NetGetDCName.

NET_API_STATUS NetGetDCName(

LPWSTR servername,  
LPWSTR domainname,  
LPBYTE *bufptr  
);  

Parameters

servername

Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.

domainname

Pointer to a Unicode string containing the name of the domain. A NULL pointer or string indicates that the function returns the name of the domain controller for the primary domain.

bufptr

Returns a pointer to an allocated buffer containing the server name of the PDC of the domain. The server name is prefixed by \\. The buffer should be deallocated using NetApiBufferFree.

Return Values

If the function succeeds, the return value is NERR_Success.

If the function fails, the return value is one of the following error codes.

Value Meaning
NERR_DCNotFound Could not find the domain controller for the domain.
ERROR_INVALID_NAME The name could not be found.

See Also

NetGetAnyDCName