<div class="content" name="NetrDfsRemove" uuid="89a016c8-3484-49e6-bb48-30cdfd5f8f58"><p>The NetrDfsRemove method removes a link or a link target
from a <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_6a3f0be9-b9b4-49df-9d1c-a3b89e4e9890" data-linktype="relative-path">DFS namespace</a>. A
link can be removed regardless of the number of targets associated with it. </p><p>The NetrDfsRemove method has the following <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_9c5903c1-1477-4181-b451-3ba1e34a0c0c" data-linktype="relative-path">MIDL</a> syntax.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrDfsRemove(
   [in, string] WCHAR* DfsEntryPath,
   [in, unique, string] WCHAR* ServerName,
   [in, unique, string] WCHAR* ShareName
 );
</pre></div>
</dd></dl><p><b>DfsEntryPath: </b>The pointer to the <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_0611e93d-f0e7-42ee-a591-d77ebcbb6619" data-linktype="relative-path">DFS link</a> path that contains
the name of an existing link.</p><p><b>ServerName: </b>The pointer to a null-terminated <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_c305d0ab-8b94-461a-bd76-13b40cb8c4d8" data-linktype="relative-path">Unicode</a> <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_44e2f830-c28b-41e3-8c3c-d0bb576ed9fb" data-linktype="relative-path">DFS link target</a> host name
string. Clients MUST set <i>ServerName</i> to a NULL pointer in requests to
remove the link and all its link targets.</p><p><b>ShareName: </b>The pointer to a null-terminated
Unicode DFS link target <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_3c179f10-1793-4268-96eb-de4d85a32060" data-linktype="relative-path">share
name</a> string. This can also be a share name with a path relative to the <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_a49a79ea-dac7-4016-9a84-cf87161db7e3" data-linktype="relative-path">share</a>, for example,
&#34;share1\mydir1\mydir2&#34;. Clients MUST set <i>ShareName</i> to a NULL
pointer in requests to remove the link and all its link targets.</p><p><b>Return Values: </b>This method MUST return 0 on
success and a nonzero error code on failure. The method can return any specific
error code value, as specified in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a>.
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>0x00000000 ERROR_SUCCESS</td>
  <td>Successful completion.</td>
 </tr><tr>
  <td>0x00000002 ERROR_FILE_NOT_FOUND</td>
  <td>The specified DFS link target was not found as a target of the specified DFS link.</td>
 </tr><tr>
  <td>0x00000005 ERROR_ACCESS_DENIED</td>
  <td>Permission to perform the operation was denied.</td>
 </tr><tr>
  <td>0x00000057 ERROR_INVALID_PARAMETER</td>
  <td>An incorrect parameter was specified.</td>
 </tr><tr>
  <td>0x00000032 ERROR_NOT_SUPPORTED</td>
  <td>The method does not support a domain-based namespace.</td>
 </tr><tr>
  <td>0x00000490 ERROR_NOT_FOUND</td>
  <td>The specified DFS namespace or DFS link does not exist.</td>
 </tr></tbody></table>
</dd></dl><p>The NetrDfsRemove method SHOULD<a id="Appendix_A_Target_49"></a><a aria-label="Product behavior note 49" href="3a466440-1ef6-4439-b4e2-be9eaddeb511#Appendix_A_49" data-linktype="relative-path">&lt;49&gt;</a> support a
<a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_133ab305-ad75-4b38-8ec9-40bc0dc3b594" data-linktype="relative-path">domain-based DFS namespace</a>.
If it does not support a domain-based DFS namespace it MUST return
ERROR_NOT_SUPPORTED.</p><p>The server MUST verify the existence of the DFS namespace
that the <i>DfsEntryPath</i> parameter specifies. If the namespace does not
exist, the server MUST return ERROR_NOT_FOUND.</p><p>The server MUST verify the existence of the DFS link <i>DfsEntryPath</i>
parameter specifies. If that existence check fails, the server MUST return
ERROR_NOT_FOUND.</p><p>The server MUST verify the existence of the DFS link target
of the DFS link that the <i>ServerName</i> and <i>RootShare</i> parameters
specify. If that existence check fails, the server MUST return
ERROR_FILE_NOT_FOUND.</p><p>If the <i>ServerName</i> and <i>ShareName</i> parameters are
both NULL, the server MUST remove the link and all its link targets. If the <i>ServerName</i>
and <i>ShareName</i> are not NULL, the server MUST remove the specified link
target. If the specific target is the last target of the link, the server MUST
remove the link as well. If only one of <i>ServerName</i> or <i>ShareName</i>
is NULL, the server MUST return ERROR_INVALID_PARAMETER.</p><p>The server MUST synchronously update the following fields in
the DFS metadata for a stand-alone DFS namespace.</p><table><thead>
  <tr>
   <th>
   <p>Operation</p>
   </th>
   <th>
   <p>DFS metadata changes required</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>Remove link</td>
  <td>Remove corresponding NamespaceElement from NamespaceElementsList.</td>
 </tr><tr>
  <td>Remove link target</td>
  <td>Remove Target from the TargetsList of the NamespaceElement, and update the TargetCount.</td>
 </tr></tbody></table><p>The server MUST update the following fields in the <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_e8de88fd-d760-46fa-ad77-76961fa20aea" data-linktype="relative-path">DFS metadata</a> for a <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_2aad5e61-ffe9-406e-a192-328c5327ee72" data-linktype="relative-path">domainv1-based DFS namespace</a>.</p><table><thead>
  <tr>
   <th>
   <p>Operation</p>
   </th>
   <th>
   <p>DFS metadata changes required</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>Remove link</td>
  <td>Remove DFSNamespaceLinkBLOB; update BLOBElementCount.</td>
 </tr><tr>
  <td>Remove link target</td>
  <td>Update TargetCount in existing DFSTargetListBLOB, remove TargetEntryBLOB. Update DFSTargetListBLOBSize, update BLOBDataSize of DFSNamespaceLinkBLOB.</td>
 </tr></tbody></table><p>The server MUST update the following fields in the DFS
metadata for a <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_8099f7c1-2a31-4a20-81e6-824689bd9c5a" data-linktype="relative-path">domainv2-based
DFS namespace</a>.</p><table><thead>
  <tr>
   <th>
   <p>Operation</p>
   </th>
   <th>
   <p>DFS metadata Changes Required</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>Remove link</td>
  <td>Remove the DFS link object.</td>
 </tr><tr>
  <td>Remove link target</td>
  <td>Update TargetCount and totalStringLengthInBytes attributes in msDFS-TargetListv2; update msDFS-LastModifiedv2.</td>
 </tr></tbody></table><p>A remove link operation in a domainv2-based DFS namespace
first creates a <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_ea6b6f3f-6bed-4622-aaca-fd7df28badb9" data-linktype="relative-path">dynamic
object</a> for the entry to be deleted. To create a dynamic object, the server
MUST do the following:</p><ul><li><p><span><span> 
</span></span>Set the object class to msDFS-DeletedLinkv2; a normal DFS link <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_45643bfb-b4c4-432c-a10f-b98790063f8d" data-linktype="relative-path">LDAP</a> entry&#39;s object class
is msDFS-Linkv2.</p>
</li><li><p><span><span> 
</span></span>Set the deleted DFS link&#39;s identity <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_f49694cc-c350-462d-ab8e-816f0103c6c1" data-linktype="relative-path">GUID</a>.</p>
</li><li><p><span><span> 
</span></span>Set an updated msDFS-LastModifiedv2 time-stamp attribute.</p>
</li></ul><p>If the dynamic object is created successfully, the original
link LDAP entry is then deleted. If the delete is successful, the dynamic
object is left intact; otherwise, the dynamic object is itself deleted. The
advantage of using a dynamic object is that directory services perform garbage
collection.</p><p>The server MUST synchronously update the DFS metadata of a
domain-based DFS namespace.</p><p>If <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_cf94d206-f71c-4ca1-891a-24c83f533e45" data-linktype="relative-path">DFS
root scalability mode</a> is not enabled for the domain-based DFS namespace,
the server MUST notify other <a href="a9bc4403-a862-48b9-b99b-1b44a887d177#gt_ac90b498-3ba4-48d6-bcd6-5495f1654671" data-linktype="relative-path">DFS
root targets</a> of the change in DFS metadata by asynchronously issuing a <a href="7b033d5b-8d26-4931-8b3d-7aa35e441fb0" data-linktype="relative-path">NetrDfsSetInfo</a> method with
the <i>Level</i> parameter 101, and with the <b>State</b> field of <a href="af9d607e-04e5-4722-8d00-76cf9c7b69f9" data-linktype="relative-path">DFS_INFO_101</a> set to
DFS_VOLUME_STATE_RESYNCHRONIZE.<a id="Appendix_A_Target_50"></a><a aria-label="Product behavior note 50" href="3a466440-1ef6-4439-b4e2-be9eaddeb511#Appendix_A_50" data-linktype="relative-path">&lt;50&gt;</a><a id="Appendix_A_Target_51"></a><a aria-label="Product behavior note 51" href="3a466440-1ef6-4439-b4e2-be9eaddeb511#Appendix_A_51" data-linktype="relative-path">&lt;51&gt;</a></p></div>