Partager via


3.1.4.16 NetrShareCheck (Opnum 20)

The NetrShareCheck method checks whether a server is sharing a device.

 NET_API_STATUS NetrShareCheck(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in, string] WCHAR* Device,
   [out] DWORD* Type
 );

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 (see [C706] sections 4.3.5 and 5.1.5.2). The server MUST ignore this parameter.

Device: A pointer to a null-terminated UTF-16 string that specifies the name of the device to check for shared access.

Type: A pointer to a DWORD that receives the type of the shared device. This parameter is set only if the method returns successfully. On success, the server MUST set this parameter as specified in section 2.2.2.4, except that STYPE_SPECIAL is not returned.

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.

0x00000008

ERROR_NOT_ENOUGH_MEMORY

Not enough storage is available to process this command.

0x00000907

NERR_DeviceNotShared

The device is not shared.

In response to a NetrShareCheck request, the server MUST scan through the ShareList. For each share, if Share.LocalPath, as specified in [MS-SMB2] section 3.3.1.6 or [MS-CIFS] section 3.3.1.2, points to the device or volume specified by the caller, the server MUST return the type of the matching device in the Type parameter. The type can be one of the values that are listed in Share Types (section 2.2.2.4). In response to a NetrShareCheck message, the server MUST check whether it is sharing a device and return a response to the client.

The Device parameter specifies the name of the shared device to check for. The server MUST enumerate the active shared devices, and if it finds a match to the Device parameter, the server MUST return the type of the matching device in the Type parameter. The type can be one of the values that are listed in Share Types. The server MUST set the STYPE_CLUSTER_FS, STYPE_CLUSTER_SOFS, and STYPE_CLUSTER_DFS bits of the Type parameter to zero; the client MUST ignore them on receipt.

If no match is found, the server MUST fail the call by using an NERR_DeviceNotShared error code.

The server does not enforce any security measures when it processes this call.