NetDfsRemoveRootTarget function (lmdfs.h)

Removes a DFS root target from a domain-based DFS namespace. If the root target is the last root target in the DFS namespace, this function removes the DFS namespace. This function can also be used to remove a stand-alone DFS namespace.

Syntax

NET_API_STATUS NET_API_FUNCTION NetDfsRemoveRootTarget(
  [in]           LPWSTR pDfsPath,
  [in, optional] LPWSTR pTargetPath,
  [in]           ULONG  Flags
);

Parameters

[in] pDfsPath

Pointer to a string that specifies the Universal Naming Convention (UNC) path of a DFS namespace.

For a stand-alone DFS namespace, this string should be in the following form:

\\ServerName\DfsName

where ServerName is the name of the server that hosts the DFS root target and DfsName is the name of the DFS namespace.

For a domain-based DFS namespace, this string should be in the following form:

\\DomainName\DomDfsName

where DomainName is the name of the domain that hosts the domain-based DFS namespace and DomDfsName is the name of the DFS namespace.

[in, optional] pTargetPath

Pointer to a null-terminated Unicode string that specifies the UNC path of a DFS root target for the DFS namespace that is specified in the pDfsPath parameter.

For a stand-alone DFS namespace, this parameter must be NULL. For a domain-based DFS namespace, the string should be in the following form:

\\ServerName\RootShare

where ServerName is the name of the server that hosts the DFS root target and RootShare is the name of the folder on the server.

[in] Flags

A flag that specifies the type of removal operation. For a stand-alone DFS namespace, this parameter must be zero. For a domain-based DFS namespace, it can be zero or the following value. If it is zero, this indicates a normal removal operation.

DFS_FORCE_REMOVE (0x80000000)

If this flag is specified for a domain-based DFS namespace, the root target is removed even if it is not accessible.

Return value

If the function succeeds, the return value is NERR_Success.

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

Remarks

The caller must have Administrator privileges on the DFS server.

The following list shows which parameter values you should specify, according to the desired result.

pDfsPath parameter pTargetPath parameter Result
\\DomainName\DomDfsName \\ServerName\RootShare Delete a Windows 2000 mode or Windows Server 2008 mode domain-based DFS root target. If the target is the last root target for the DFS namespace, the function also deletes the DFS namespace.
\\ServerName\DfsName NULL Delete a stand-alone DFS namespace.

Requirements

Requirement Value
Minimum supported client Windows Vista with SP1
Minimum supported server Windows Server 2008
Target Platform Windows
Header lmdfs.h (include LmDfs.h, Lm.h)
Library Netapi32.lib
DLL Netapi32.dll

See also

Distributed File System (DFS) Functions

NetDfsAddRootTarget

Network Management Functions

Network Management Overview