<div class="content"><p>The R_SetData method sets a data item for a particular node
in the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_086b13f2-2715-4000-a16c-6acc3d59cc19" data-linktype="relative-path">metabase</a>.</p><dl>
<dd>
<div><pre> HRESULT R_SetData(
   [in] METADATA_HANDLE hMDHandle,
   [unique, in, string] LPCWSTR pszMDPath,
   [in] METADATA_RECORD* pmdrMDData
 );
</pre></div>
</dd></dl><p><b>hMDHandle: </b>An unsigned 32-bit integer value
specifying a handle to a node in the metabase with write permissions as
returned by the <a href="a54be1d0-009a-493d-a53e-e2f7fbe87293" data-linktype="relative-path">OpenKey</a>
method.</p><p><b>pszMDPath: </b>A pointer to a Unicode string that
contains the path of the node that stores the entry, relative to the path of
the <i>hMDHandle</i> parameter.</p><p><b>pmdrMDData: </b>A pointer to a <a href="10608402-8619-4ea9-be90-d57f21393ce0" data-linktype="relative-path">METADATA_RECORD</a> structure
that contains the data to set.</p><p><b>Return Values: </b>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 <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
values, see <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>S_OK</p>
  </td>
  <td>
  <p>The call was successful.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80070003</p>
  <p>ERROR_PATH_NOT_FOUND</p>
  </td>
  <td>
  <p>The system cannot find the path specified.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80070005</p>
  <p>E_ACCESSDENIED</p>
  </td>
  <td>
  <p>General access denied error.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80070057</p>
  <p>E_INVALIDARG</p>
  </td>
  <td>
  <p>An invalid parameter value was specified.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x800CC808</p>
  <p>MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE</p>
  </td>
  <td>
  <p>The <b>METADATA_SECURE</b> attribute cannot be removed
  from a data item via the <a href="7f8d396e-6eff-4141-a61c-859262b1e0a7" data-linktype="relative-path">R_GetData</a>
  method. Use the <a href="16ad0208-862f-463a-8bcb-39f399d06246" data-linktype="relative-path">DeleteData</a>
  method to remove the secure data.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80070008</p>
  <p>ERROR_NOT_ENOUGH_MEMORY</p>
  </td>
  <td>
  <p>There is not enough memory to complete the operation.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_e127848e-c66d-427d-b3aa-9f904fa4ada7" data-linktype="relative-path">opnum</a>
field value for this method is 9.</p><p>When processing this call, the server MUST do the following:</p><ul><li><p><span><span> 
</span></span>Check whether the handle, <i>hMDHandle</i>, was opened for write
access. If not, return E_ACCESSDENIED.</p>
</li><li><p><span><span> 
</span></span>Check the path of the node indicated by <i>hMDHandle</i> and <i>pszMDPath</i>.
If the path does not exist, return ERROR_PATH_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>If data with the specified identifier does not exist at the
specified node, create a new data item as specified by the <i>pmdrMDData</i>
parameter.</p>
</li><li><p><span><span> 
</span></span>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 <i>pmdrMDData</i>
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 <b>dwMDAttributes</b> member of the <i>pmdrMDData</i>
parameter, the server SHOULD NOT update the existing data item and SHOULD
return MD_ERROR_CANNOT_REMOVE_SECURE_ATTRIBUTE.<a id="Appendix_A_Target_17"></a><a aria-label="Product behavior note 17" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_17" data-linktype="relative-path">&lt;17&gt;</a></p>
</li></ul><p>The <i>pbMDData</i> and <i>dwMDDataLen</i> fields of
METADATA_RECORD (referenced by the <i>pmdrMDData</i> parameter) MUST be
interpreted using the following steps:</p><ol><li><p><span>    </span>Check whether
the <i>dwMDAttributes</i> member of the METADATA_RECORD structure has the
METADATA_SECURE secure flag set.</p>
</li><li><p><span>    </span>If the
METADATA_SECURE secure flag is set, the <i>pbMDData</i> member of
METADATA_RECORD structure points to the encrypted data BLOB, and the <i>dwMDDataLen</i>
field is set to the size of the encrypted data. The encrypted data BLOB is
stored in the <a href="bbe15a83-a32d-48a3-9564-8dacea965e83" data-linktype="relative-path">IIS_CRYPTO_BLOB</a>
message format with the <b>BlobSignature</b> field set to
ENCRYPTED_DATA_BLOB_SIGNATURE. </p>
<ul><li><p><span><span>  </span></span>Decrypt
the data pointed to by the <i>pbMDData</i> field based on the procedure
described in section <a href="f9606fd5-4add-4c19-8169-ab860dfa9494" data-linktype="relative-path">3.1.4.1.3</a>.</p>
</li></ul></li><li><p><span>    </span>If the
METADATA_SECURE secure flag is not set, the data referenced by the <i>pbMDData</i>
member of METADATA_RECORD is the cleartext data, and the <i>dwMDDataLen</i>
field is its length.</p>
</li></ol></div>