NetAddAlternateComputerName function (lmjoin.h)
The NetAddAlternateComputerName function adds an alternate name for the specified computer.
Syntax
NET_API_STATUS NET_API_FUNCTION NetAddAlternateComputerName(
[in, optional] LPCWSTR Server,
[in] LPCWSTR AlternateName,
[in, optional] LPCWSTR DomainAccount,
[in, optional] LPCWSTR DomainAccountPassword,
[in] ULONG Reserved
);
Parameters
[in, optional] Server
A pointer to a constant string that specifies the name of the computer on which to execute this function. If this parameter is NULL, the local computer is used.
[in] AlternateName
A pointer to a constant string that specifies the alternate name to add. This name must be in the form of a fully qualified DNS name.
[in, optional] DomainAccount
A pointer to a constant string that specifies the domain account to use for accessing the machine account object for the computer specified in the Server parameter in Active Directory. If this parameter is NULL, then the credentials of the user executing this routine are used.
This parameter is not used if the server to execute this function is not joined to a domain.
[in, optional] DomainAccountPassword
A pointer to a constant string that specifies the password matching the domain account passed in the DomainAccount parameter. If this parameter is NULL, then the credentials of the user executing this routine are used.
This parameter is ignored if the DomainAccount parameter is NULL. This parameter is not used if the server to execute this function is not joined to a domain.
[in] Reserved
Reserved for future use. This parameter should be NULL.
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 or one of the system error codes.
Return code | Description |
---|---|
|
Access is denied. This error is returned if the caller was not a member of the Administrators local group on the target computer. |
|
A name parameter is incorrect. This error is returned if the AlternateName parameter does not contain valid name. |
|
A parameter is incorrect. This error is returned if the DomainAccount parameter does not contain a valid domain. This error is also returned if the DomainAccount parameter is not NULL and the DomainAccountPassword parameter is not NULL but does not contain a Unicode string. |
|
Not enough memory is available to process this command. |
|
The request is not supported. This error is returned if the target computer specified in the Server parameter on which this function executes is running on Windows 2000 and earlier. |
|
The Workstation service has not been started. |
|
A remote procedure call is already in progress for this thread. |
|
The remote procedure call protocol sequence is not supported. |
Remarks
The NetAddAlternateComputerName function is supported on Windows XP and later.
The NetAddAlternateComputerName function is used to set secondary network names for computers. The primary name is the name used for authentication and maps to the machine account name.
The NetAddAlternateComputerName function requires that the caller is a member of the Administrators local group on the target computer.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | lmjoin.h (include Lm.h) |
Library | Netapi32.lib |
DLL | Netapi32.dll |