NetGetAnyDCName function (lmaccess.h)
The NetGetAnyDCName function returns the name of any domain controller (DC) for a domain that is directly trusted by the specified server.
Applications that support DNS-style names should call the DsGetDcName function. This function can locate any DC in any domain, whether or not the domain is directly trusted by the specified server.
Syntax
NET_API_STATUS NET_API_FUNCTION NetGetAnyDCName(
LPCWSTR ServerName,
LPCWSTR DomainName,
LPBYTE *Buffer
);
Parameters
ServerName
Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used. For more information, see the following Remarks section.
DomainName
Pointer to a constant string that specifies the name of the domain. If this parameter is NULL, the name of the domain controller for the primary domain is used. For more information, see the following Remarks section.
Buffer
Return value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Return code | Description |
---|---|
|
No domain controllers could be found. |
|
The specified domain is not a trusted domain. |
|
The client side of the trust relationship is broken. |
|
The server side of the trust relationship is broken or the password is broken. |
|
The server that responded is not a proper domain controller of the specified domain. |
Remarks
No special group membership is required to successfully execute the NetGetAnyDCName function.
If servername specifies a stand-alone workstation or a stand-alone server, no domainname is valid.
If servername specifies a workstation that is a member of a domain, or a server that is a member of a domain, the domainname must be in the same domain as servername.
If servername specifies a domain controller, the domainname must be one of the domains trusted by the domain for which the server is a controller. The domain controller that this call finds has been operational at least once during this call.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | lmaccess.h (include Lm.h) |
Library | Netapi32.lib |
DLL | Netapi32.dll |