<div class="content" name="R_GetData" uuid="7f8d396e-6eff-4141-a61c-859262b1e0a7"><p>The R_GetData method returns a data entry from 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_GetData(
   [in] METADATA_HANDLE hMDHandle,
   [unique, in, string] LPCWSTR pszMDPath,
   [in, out] METADATA_RECORD* pmdrMDData,
   [out] DWORD* pdwMDRequiredDataLen,
   [out] IIS_CRYPTO_BLOB** ppDataBlob
 );
</pre></div>
</dd></dl><p><b>hMDHandle: </b>An unsigned 32-bit integer value
containing an open metabase handle specifying the key to be queried.</p><p><b>pszMDPath: </b>A pointer to a Unicode string that
contains the path of the node containing the data, 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 describes the requested data.</p><p><b>pdwMDRequiredDataLen: </b>A pointer to an integer
value that contains the buffer length required, in bytes, to contain the
decrypted data referenced by the <i>ppDataBlob</i> parameter.</p><p><b>ppDataBlob: </b>An <a href="bbe15a83-a32d-48a3-9564-8dacea965e83" data-linktype="relative-path">IIS_CRYPTO_BLOB</a> structure
containing the requested data value as encrypted opaque data.</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>0x00000000 S_OK</td>
  <td>The call was successful.</td>
 </tr><tr>
  <td>0x80070003 ERROR_PATH_NOT_FOUND</td>
  <td>The system cannot find the path specified.</td>
 </tr><tr>
  <td>0x80070005 E_ACCESSDENIED</td>
  <td>General access denied error.</td>
 </tr><tr>
  <td>0x80070057 E_INVALIDARG</td>
  <td>An invalid parameter value was specified.</td>
 </tr><tr>
  <td>0x8007007A ERROR_INSUFFICIENT_BUFFER</td>
  <td>The data area passed to a system call is too small.</td>
 </tr><tr>
  <td>0x800CC801 MD_ERROR_DATA_NOT_FOUND</td>
  <td>The specified metadata was not found.</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 10. </p><p>The client describes the data it is requesting by
initializing the METADATA_RECORD passed in the <i>pmdrMDData</i> parameter.</p><p>The client indicates how much decrypted data it is ready to
receive by passing the number of bytes in the <b>dwMDDataLen</b> field of the <i>pmdrMDData</i>
parameter.</p><p>The <i>pbMDData</i> field of the <i>pmdrMDData</i> parameter
is not used to transfer the actual data value. The client MUST set the <i>pbMDData</i>
field of <i>pmdrMDData</i> to NULL. The IIS_CRYPTO_BLOB structure is used to
transfer the actual data value returned by the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a> and can be encrypted
when the server sends data marked as secure.</p><p>When processing this call, the server MUST do the following:</p><ul><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 a data value matching the one described by the <i>pmdrMDData</i>
parameter is not found at the node indicated by <i>hMDHandle</i> and <i>pszMDPath</i>,
return MD_ERROR_DATA_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>If value passed by the client in the <b>dwMDDataLen</b> field of
the <i>pmdrMDData</i> parameter is less than the size of the unencrypted data
value, set the value of <i>pdwMDRequiredDataLen</i> to the size of the
unencrypted data value and return ERROR_INSUFFICIENT_BUFFER.</p>
</li></ul><p>The following set of steps MUST be performed by the server
to encrypt or encode a data value and build an IIS_CRYPTO_BLOB structure to be
sent by the server.</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:</p>
<ul><li><p><span><span>  </span></span>Encrypt
the data value based on the procedure described in section <a href="60aa6c05-c259-42e8-a7f0-37516b75c165" data-linktype="relative-path">3.1.4.1.2</a>. The encrypted
data BLOB will be stored in the IIS_CRYPTO_BLOB message format with the <b>BlobSignature</b>
field set to the ENCRYPTED_DATA_BLOB_SIGNATURE signature.</p>
</li></ul></li><li><p><span>    </span>If the
METADATA_SECURE secure flag is not set:</p>
<ul><li><p><span><span>  </span></span>Build
the IIS_CRYPTO_BLOB message with the <b>BlobSignature</b> field set to
CLEARTEXT_DATA_BLOB_SIGNATURE. Store the cleartext data in the <b>BlobData</b>
field. Set the <b>BlobDataLength</b> field to match the length of the <b>BlobData</b>
field.</p>
</li></ul></li></ol></div>