3.1.4.27 R_SetData (Opnum 9)

The R_SetData method sets a data item for a particular node in the metabase.

 HRESULT R_SetData(
   [in] METADATA_HANDLE hMDHandle,
   [unique, in, string] LPCWSTR pszMDPath,
   [in] METADATA_RECORD* pmdrMDData
 );

hMDHandle: An unsigned 32-bit integer value specifying a handle to a node in the metabase with write permissions as returned by the OpenKey method.

pszMDPath: A pointer to a Unicode string that contains the path of the node that stores the entry, relative to the path of the hMDHandle parameter.

pmdrMDData: A pointer to a METADATA_RECORD structure that contains the data to set.

Return Values: A signed 32-bit value that indicates return status. If the method returns a negative value, it failed. If the 12-bit facility code (bits 16 27) is set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or positive values indicate success, with the lower 16 bits in positive nonzero values containing warnings or flags defined in the method implementation. For more information about Win32 error codes and HRESULT values, see [MS-ERREF].

Return value/code

Description

0x00000000

S_OK

The call was successful.

0x80070003

ERROR_PATH_NOT_FOUND

The system cannot find the path specified.

0x80070005

E_ACCESSDENIED

General access denied error.

0x80070057

E_INVALIDARG

An invalid parameter value was specified.

0x800CC808

MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE

The METADATA_SECURE attribute cannot be removed from a data item via the R_GetData method. Use the DeleteData method to remove the secure data.

0x80070008

ERROR_NOT_ENOUGH_MEMORY

There is not enough memory to complete the operation.

The opnum field value for this method is 9.

When processing this call, the server MUST do the following:

  • Check whether the handle, hMDHandle, was opened for write access. If not, return E_ACCESSDENIED.

  • Check the path of the node indicated by hMDHandle and pszMDPath. If the path does not exist, return ERROR_PATH_NOT_FOUND.

  • If data with the specified identifier does not exist at the specified node, create a new data item as specified by the pmdrMDData parameter.

  • If data with the specified identifier does exist at the specified node, update the data item with the properties and data value specified by the pmdrMDData parameter. Before updating the existing data item, the server SHOULD check whether it has the METADATA_SECURE flag set. If this flag is set on the existing data item but is not set in the dwMDAttributes member of the pmdrMDData parameter, the server SHOULD NOT update the existing data item and SHOULD return MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE.<17>

The pbMDData and dwMDDataLen fields of METADATA_RECORD (referenced by the pmdrMDData parameter) MUST be interpreted using the following steps:

  1. Check whether the dwMDAttributes member of the METADATA_RECORD structure has the METADATA_SECURE secure flag set.

  2. If the METADATA_SECURE secure flag is set, the pbMDData member of METADATA_RECORD structure points to the encrypted data BLOB, and the dwMDDataLen field is set to the size of the encrypted data. The encrypted data BLOB is stored in the IIS_CRYPTO_BLOB message format with the BlobSignature field set to ENCRYPTED_DATA_BLOB_SIGNATURE.

    • Decrypt the data pointed to by the pbMDData field based on the procedure described in section 3.1.4.1.3.

  3. If the METADATA_SECURE secure flag is not set, the data referenced by the pbMDData member of METADATA_RECORD is the cleartext data, and the dwMDDataLen field is its length.