<div class="content"><p> </p><p>The NetrServerAliasAdd method attaches an alias name to an
existing <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a></span> name and
inserts Alias objects into <b>AliasList</b>, through which the shared resource
can be accessed either with server name or alias name. An alias is used to
identify which resources are visible to an <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_09dbec39-5e75-4d9a-babf-1c9f1d499625" data-linktype="relative-path">SMB</a></span> client based on
the server name presented in each tree connect request.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrServerAliasAdd(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in] DWORD Level,
   [in, switch_is(Level)] LPSERVER_ALIAS_INFO InfoStruct
</pre></div>
</dd></dl><p>);</p><p><b>ServerName: </b>An <span><a href="5f8329ee-1965-4ea1-ad35-3b29fbb63232" data-linktype="relative-path">SRVSVC_HANDLE</a></span>
(section 2.2.1.1) that identifies the server. The client MUST map this
structure to an RPC binding handle (see <span><a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a></span> sections
4.3.5 and 5.1.5.2). The server MUST ignore this parameter.</p><p><b>Level: </b>Specifies the information level of the
data. It MUST be one of the following values.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0</p>
  </td>
  <td>
  <p>The buffer is of type <span><a href="79580d1c-fa06-4884-9b93-8d08d9d706cd" data-linktype="relative-path">SERVER_ALIAS_INFO_0_CONTAINER</a></span>.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p><b>InfoStruct: </b>A pointer to the <span><a href="3d17bf62-345b-4257-9b12-633828db2fa0" data-linktype="relative-path">SERVER_ALIAS_INFO</a></span>
union that contains information about the alias. The value of the <i>Level</i>
parameter determines the type of the contents of the <i>InfoStruct</i>
parameter, as the preceding table shows.</p><p><b>Return Values: </b>The method returns 0x00000000
(NERR_Success) to indicate success; otherwise, it returns a nonzero error code.
The method can take any specific error code value, as specified in <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>
section <span><a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a></span>.
The most common error codes are listed in the following table.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>NERR_Success</p>
  </td>
  <td>
  <p>The <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a></span> request
  succeeded.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000005</p>
  <p>ERROR_ACCESS_DENIED</p>
  </td>
  <td>
  <p>Access is denied.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000057</p>
  <p>ERROR_INVALID_PARAMETER</p>
  </td>
  <td>
  <p>The client request failed because the specified
  parameter is invalid.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000008</p>
  <p>ERROR_NOT_ENOUGH_MEMORY</p>
  </td>
  <td>
  <p>Not enough storage is available to process this
  command.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000846</p>
  <p>NERR_DuplicateShare</p>
  </td>
  <td>
  <p>The alias already exists.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x0000007C</p>
  <p>ERROR_INVALID_LEVEL</p>
  </td>
  <td>
  <p>The system call level is not correct.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>In response to a NetrServerAliasAdd message, the server MUST
add an alias to attach the existing server name and insert it into <b>AliasList</b>
upon successful return, or return an error code for a failure case. Multiple
alias names can be attached to the same server name.</p><p>The server name to be attached to the alias is specified in
the <b>srvai*_target</b> member of the SERVER_ALIAS_INFO structure. If the
specified target name is an empty string or does not match any <b>Transport.ServerName</b>
in the <b>TransportList</b>, the server SHOULD fail the call with an
ERROR_INVALID_PARAMETER error code.</p><p>The <i>Level</i> parameter determines the type of structure
that the client has used to specify information about the new alias. The value
of the <i>Level</i> parameter MUST be 0. If the <i>Level</i> parameter is not
equal to 0, the server MUST fail the call and return an ERROR_INVALID_LEVEL
error code.</p><p>The name of the alias to be added is specified in the <b>srvai*_alias</b>
member of the SERVER_ALIAS_INFO structure. <b>srvai*_alias</b> MUST be a
nonempty null-terminated UTF-16 string if <b>srvai*_default</b> is 0 or an
empty string if <i>srvai*_default</i> is nonzero; otherwise, the server MUST
fail the call with an ERROR_INVALID_PARAMETER error code. If <b>srvai*_alias</b>
is a nonempty string and it matches an existing Alias.alias in the <b>AliasList</b>,
the server MUST fail the call with an ERROR_INVALID_PARAMETER error code. If <b>srvai*_alias</b>
is an empty string and <b>srvai*_default</b> is set, the server MUST fail the
call with an implementation-specific error code if <b>DefaultServerName</b> is
not NULL. Otherwise, <b>DefaultServerName</b> MUST be set to <b>srvai*_target</b>
as specified in section <span><a href="98c56700-5c9d-4246-b294-1357faa9ed57" data-linktype="relative-path">3.1.1.1</a></span>.</p><p>The server MAY<a id="Appendix_A_Target_170"></a><a aria-label="Product behavior note 170" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_170" data-linktype="relative-path">&lt;170&gt;</a>
enforce security measures to verify that the caller has the required
permissions to execute this call. If the server enforces these security
measures and the caller does not have the required credentials, the server
SHOULD<a id="Appendix_A_Target_171"></a><a aria-label="Product behavior note 171" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_171" data-linktype="relative-path">&lt;171&gt;</a> fail the call.</p><p>The server MUST persist the <i>InfoStruct</i> and <i>Level</i>
parameters to a persistent configuration store. If an alias with the same
srvai0_alias and srvai0_target already exists in the store, the preexisting entry
MUST be overwritten with this entry.</p></div>