Partager via


3.2.5.1 NetShareEnum Command

The Remote Administration Protocol server MUST process NetShareEnumRequest as follows:

  1. The server MUST validate that the incoming ParamDesc field of the Remote Administration Protocol request contains the ASCII string "WrLeh"; if it does not, the server SHOULD format a Remote Administration Protocol response with the Win32ErrorCode set to ERROR_INVALID_PARAMETER (0x0057), and then return the response to the client.<67>

  2. If the information level is any value other than 0, 1, or 2, the server implementing NetShareEnum MUST set the Win32ErrorCode value in the Remote Administration Protocol response message to ERROR_INVALID_LEVEL (0x007C).

  3. The Remote Administration Protocol server MUST create a Remote Administration Protocol response message with the RAPOutParams set to the contents of a NetShareEnumResponse message. The Remote Administration Protocol server MUST enumerate the shares on the local machine as specified in [MS-SRVS] section 3.1.4.8, passing the following parameters:

    Parameter

    Value

    ServerName

    The local machine name

    InfoStruct.Level

    NetShareEnumRequest.InfoLevel

    PreferredMaximumLength

    0xFFFFFFFF

    ResumeHandle

    0

    If the enumeration call succeeds, the server MUST use the resulting TotalEntries and InfoStruct information to generate the response as follows:

    • If the InfoLevel of the NetShareEnumRequest structure is 0x0000, the Remote Administration Protocol server MUST fill in the RAPOutData field of the Remote Administration Protocol response with as many NetShareInfo0 structures as can fit within the value specified by the Remote Administration Protocol client's ReceiveBufferSize input parameter (see packing rules specified in section 2.5.11). The server MUST map between the fields of the SHARE_INFO_0 structures returned from NetrShareEnum and the NetShareInfo0 structure as follows:

      NetShareInfo0

      SHARE_INFO_0

      NetworkName

      shi0_netname, truncated to 12 characters if necessary

      The server MUST set the EntriesReturned field in NetShareEnumResponse to the number of NetShareInfo0 structures filled in the RAPOutData field of the response, and MUST set EntriesAvailable to the TotalEntries value received from the NetrShareEnum call.

    • If the InfoLevel of the NetShareEnumRequest structure is 0x0001, the Remote Administration Protocol server MUST fill in the RAPOutData field of the Remote Administration Protocol response with as many NetShareInfo1 structures as can fit within the value specified by the Remote Administration Protocol client's ReceiveBufferSize input parameter (see packing rules specified in section 2.5.11). The server MUST map between the fields of the SHARE_INFO_1 structures returned from NetrShareEnum and the NetShareInfo1 structure as follows:

      NetShareInfo1

      SHARE_INFO_1

      NetworkName

      shi1_netname, truncated to 12 characters if necessary

      Type

      shi1_type

      RemarkOffset and RemarkLength

      shi1_remark

      The server MUST set the EntriesReturned field in NetShareEnumResponse to the number of NetShareInfo1 structures filled in the RAPOutData field of the response, and MUST set EntriesAvailable to the TotalEntries value received from the NetrShareEnum call.

    • If the InfoLevel of the NetShareEnumRequest structure is 0x0002, the Remote Administration Protocol server MUST walk the shares in ShareList and fill in the RAPOutData field of the Remote Administration Protocol response with as many NetShareInfo2 structures as can fit within the value specified by the Remote Administration Protocol client's ReceiveBufferSize input parameter (see packing rules specified in section 2.5.11). The server MUST map between the SHARE_INFO_2 structures returned from NetrShareEnum and the NetShareInfo2 structure as follows:

      NetShareInfo2

      SHARE_INFO_2

      NetworkName

      shi2_netname, truncated to 12 characters if necessary

      Type

      shi2_type

      RemarkOffset and RemarkLength

      shi2_remark

      Permissions

      shi2_permissions

      MaxUses

      shi2_max_uses

      CurrentUses

      shi2_current_uses

      PathOffsetLow and PathOffsetHigh

      shi2_path

      Password

      shi2_password

      The server MUST set the EntriesReturned field in NetShareEnumResponse to the number of NetShareInfo2 structures filled in the RAPOutData field of the response, and MUST set EntriesAvailable to the TotalEntries value received from the NetrShareEnum call.

  4. If the response EntriesReturned field is less than the response EntriesAvailable field, the NetShareEnum server SHOULD set the Win32ErrorCode value in the Remote Administration Protocol response message to ERROR_MORE_DATA (0x00EA).<68>

  5. If any other errors occur during the response processing, the Remote Administration Protocol server MUST fill the Win32ErrorCode value in the Remote Administration Protocol response message with the Win32 error code corresponding to the error. Otherwise, the Remote Administration Protocol server MUST set Win32ErrorCode to ERROR_SUCCESS (0X0000).