NetGetDCName

The NetGetDCName function returns the name of the Primary Domain Controller (PDC). It does not return the name of the Backup Domain Controller (BDC) for the specified domain. Also, you cannot remote this function to a non-PDC server.

The NetGetDCName function is obsolete. It is provided only for compatibility with 16-bit versions of Windows. For NT5 and subsequent versions, Win32-based applications should use the DSGetDCName function.

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 a Unicode string which identifies 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.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in lmaccess.h.
  Import Library: Use netapi32.lib.

See Also

Networking (Net) Overview, Net Functions, NetGetAnyDCName