Platform SDK: Network Management

NetValidateName

The NetValidateName function verifies the validity of a computer name, workgroup name, or domain name.

Security Requirements

No special group membership is required to successfully execute the NetValidateName function.

NET_API_STATUS NetValidateName(
  LPCWSTR lpServer,
  LPCWSTR lpName,
  LPCWSTR lpAccount,
  LPCWSTR lpPassword,
  NETSETUP_NAME_TYPE NameType
);

Parameters

lpServer
[in] Pointer to a constant null-terminated Unicode character string that specifies the name of the computer on which to call the function. The string must begin with \\. If this parameter is NULL, the local computer is used.
lpName
[in] Pointer to a constant null-terminated Unicode character string that specifies the computer name, workgroup name, or domain name to validate.
lpAccount
[in] If the lpName parameter is a domain name, this parameter points to an account name to use when connecting to the domain controller. The string must specify either a domain NetBIOS name and user account (for example, "REDMOND\user") or the user principal name (UPN) of the user in the form of an Internet-style login name (for example, "someone@microsoft.com"). If this parameter is NULL, the caller's context is used.
lpPassword
[in] If the lpAccount parameter specifies an account name, this parameter must point to the password to use when connecting to the domain controller. Otherwise, this parameter must be NULL.
NameType
[in] Specifies the type of validation to perform. This parameter must be one of the following values.
typedef enum  _NETSETUP_NAME_TYPE {

    NetSetupUnknown = 0,
    NetSetupMachine,
    NetSetupWorkgroup,
    NetSetupDomain,
    NetSetupNonExistentDomain,
#if(_WIN32_WINNT >= 0x0500)
    NetSetupDnsMachine
#endif

} NETSETUP_NAME_TYPE, *PNETSETUP_NAME_TYPE;

These values have the following meanings.
Value Meaning
NetSetupMachine Verify that the NetBIOS computer name is valid and that it is not in use.
NetSetupWorkgroup Verify that the workgroup name is valid.
NetSetupDomain Verify that the domain name exists and that it is a domain.
NetSetupNonExistentDomain Verify that the domain name is not in use.
NetSetupDnsMachine Verify that the DNS computer name is valid.

Return Values

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.

Value Meaning
ERROR_INVALID_PARAMETER A parameter is incorrect.
ERROR_DUP_NAME A duplicate name already exists on the network.
ERROR_NO_SUCH_DOMAIN The specified domain did not exist.
NERR_InvalidWorkgroupName The specified workgroup name is not valid.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Lmjoin.h; include Lm.h.
  Library: Use Netapi32.lib.

See Also

Network Management Overview, Network Management Functions