NetrShareDel (Opnum 18)

The NetrShareDel method deletes a share name from the ShareList, which disconnects all connections to the shared resource. If the share is sticky, all information about the share is also deleted from permanent storage.<67>

   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in, string] WCHAR* NetName,
   [in] DWORD Reserved

ServerName: An SRVSVC_HANDLE (section pointer that identifies the server. The client MUST map this structure to an RPC binding handle ([C706] sections 4.3.5 and If this parameter is NULL, the local computer is used.

NetName: A pointer to a null-terminated UTF-16 string that specifies the name of the share to delete.

Reserved: The server MUST ignore this parameter.<68>

Return Values: 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 [MS-ERREF] section 2.2. The most common error codes are listed in the following table.

Return value/code




The client request succeeded.



Access is denied.



The client request failed because the specified parameter is invalid.



Not enough storage is available to process this command.



The share name does not exist.

If ServerName does not match any Transport.ServerName in TransportList with the SVTI2_SCOPED_NAME bit set in Transport.Flags, the server MUST reset ServerName as "*".

The server MUST remove any preceding "\\" from the ServerName parameter and normalize the ServerName parameter as specified in section, passing in the updated ServerName parameter as the ServerName, and an empty string as the ShareName.

The server MUST look up the ShareList and locate a Share where NetName matches Share.ShareName and ServerName matches Share.ServerName. If no match is found, the server MUST fail the call with a NERR_NetNameNotFound error code. If a matching share is found, the server MUST remove the share from ShareList and free the share object.

If the Share is found and Share.IsPrinterShare is TRUE, PrinterShareCount MUST be decreased by 1. If PrinterShareCount becomes 0, the server MUST invoke the events as specified in section, providing SV_TYPE_PRINTQ_SERVER as input parameter.

The server MUST delete the Share by invoking underlying server event as specified in [MS-CIFS] section and [MS-SMB2] section, providing tuple <ServerName, NetName> as input parameters. If either CIFS or SMB2 servers return STATUS_SUCCESS, the server MUST return NERR_Success. Otherwise, the server MUST fail the call with an implementation-dependent error.

The server SHOULD<69> enforce security measures to verify that the caller has the required permissions to execute this routine. If the caller does not have the required credentials, the server SHOULD<70> fail the call.