Platform SDK: Network Management

NetDfsRemove

The NetDfsRemove function removes a server share from a Distributed File System (Dfs) link. If the specified share is the last share associated with the Dfs link, then the NetDfsRemove function also removes the link.

Security Requirements

Administrator privileges are required to successfully execute the NetDfsRemove function.

NET_API_STATUS NetDfsRemove(
  LPWSTR DfsEntryPath, // Dfs entry path for the junction point
  LPWSTR ServerName,   // name of server exporting the storage
  LPWSTR ShareName     // name of share exporting the storage
);

Parameters

DfsEntryPath
[in] Pointer to a null-terminated Unicode character string that specifies the Universal Naming Convention path of a Dfs link in a named Dfs root. The string must be in one of two forms. The first form is as follows:
\\Dfsname\sharename\path_to_link 

where Dfsname is the name of a Windows NT/Windows 2000 server that hosts the root of a stand-alone Dfs implementation; sharename is the name of a share published on the Dfs host server; and path_to_link specifies the path on the physical share.

The second form is as follows:

\\DomainName\DomDfsname\path_to_link

where DomainName is the name of a Windows NT/Windows 2000 domain that hosts the Dfs root; DomDfsname is the name of the root of a domain-based Dfs implementation published in the domain's directory service; and path_to_link specifies the path on the physical share.

Windows 95/98: The DomDfsname must be identical to the name of the share that hosts the root of the domain-based Dfs.

ServerName
[in] Pointer to a null-terminated Unicode character string that specifies the name of the host server that the Dfs link references. The string must begin with \\.
ShareName
[in] Pointer to a null-terminated Unicode character string that specifies the name of the share on the host server that the Dfs link references.

Return Values

If the function succeeds, the return value is NERR_Success.

If the function fails, the return value is a Win32 API error code. For a list of error codes, see Error Codes.

Remarks

The following code sample demonstrates how to remove a server share from a Dfs link using a call to the NetDfsRemove function.

#define UNICODE
#include <windows.h>
#include <lm.h>
#include <lmdfs.h>
#include <stdio.h>

void wmain(int argc, wchar_t *argv[ ])
{
   DWORD res;
   //
   // All parameters are required.
   //
   if (argc<4)
      wprintf(L"Syntax: %s DfsEntryPath ServerName ShareName\n", argv[0]);
   else
   {
      //
      // Call the NetDfsRemove function 
      //  to remove the Dfs link.
      //
      res = NetDfsRemove(argv[1], argv[2], argv[3]);
      //
      // Display the result of the call.
      //
      if(res==0)
         printf("Removed Dfs link\n");
      else
         printf("Error: %u\n", res);
   }
   return;
}

Requirements

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

See Also

Network Management Overview, Network Management Functions, Distributed File System (Dfs) Functions, NetDfsAdd, NetDfsEnum, NetDfsRemoveStdRoot, NetDfsRemoveFtRoot