3.1.4.12 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.<68>
-
NET_API_STATUS NetrShareDel( [in, string, unique] SRVSVC_HANDLE ServerName, [in, string] WCHAR* NetName, [in] DWORD Reserved );
ServerName: An SRVSVC_HANDLE (section 2.2.1.1) pointer that identifies the server. The client MUST map this structure to an RPC binding handle ([C706] sections 4.3.5 and 5.1.5.2). 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.<69>
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
Description
0x00000000
NERR_Success
The client request succeeded.
0x00000005
ERROR_ACCESS_DENIED
Access is denied.
0x00000057
ERROR_INVALID_PARAMETER
The client request failed because the specified parameter is invalid.
0x00000008
ERROR_NOT_ENOUGH_MEMORY
Not enough storage is available to process this command.
0x00000906
NERR_NetNameNotFound
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 3.1.6.8, 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 3.1.6.10, 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 3.3.4.11 and [MS-SMB2] section 3.3.4.15, 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<70> 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<71> fail the call.