<div class="content" name="RSetServiceObjectSecurity" uuid="ea93548f-3917-4626-bef7-2f3f8fa39299"><p>The RSetServiceObjectSecurity method sets the <span><a href="../ms-dtyp/7d4dac05-9cef-4563-a058-f108abecce1d" data-linktype="relative-path">SECURITY_DESCRIPTOR</a></span>
structure associated with a service object.</p><dl>
<dd>
<div><pre> DWORD RSetServiceObjectSecurity(
   [in] SC_RPC_HANDLE hService,
   [in] SECURITY_INFORMATION dwSecurityInformation,
   [in, size_is(cbBufSize)] LPBYTE lpSecurityDescriptor,
   [in] DWORD cbBufSize
 );
</pre></div>
</dd></dl><p><b>hService: </b>An <span><a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">SC_RPC_HANDLE</a></span>
(section 2.2.4) data type that defines the handle to a <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_1fbb7936-8437-4e3d-b62f-47df3be07721" data-linktype="relative-path">service
record</a></span> or to the SCM database that MUST have been created previously
using one of the open methods specified in section <span><a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a></span>.</p><p><b>dwSecurityInformation: </b>A <span><a href="deed7901-ba2b-45ce-ba66-e071928bdfc1" data-linktype="relative-path">SECURITY_INFORMATION (section 2.2.1)</a></span>
type definition that specifies the security information being set.</p><p><b>lpSecurityDescriptor: </b>A pointer to a buffer of
bytes that contains the new security information.</p><p><b>cbBufSize: </b>Size, in bytes, of the buffer
pointed to by the <i>lpSecurityDescriptor</i> parameter.</p><p><b>Return Values: </b>The method returns 0x00000000
(ERROR_SUCCESS) on success; otherwise, it returns one of the following error
codes.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>5 ERROR_ACCESS_DENIED</td>
  <td>The required access rights had not been granted to the caller when the RPC context handle was created.</td>
 </tr><tr>
  <td>6 ERROR_INVALID_HANDLE</td>
  <td>The handle is no longer valid.</td>
 </tr><tr>
  <td>87 ERROR_INVALID_PARAMETER</td>
  <td>A parameter that was specified is invalid.</td>
 </tr><tr>
  <td>1072 ERROR_SERVICE_MARKED_FOR_DELETE</td>
  <td>The RDeleteService method has been called with an RPC context handle identifying the same service record as the hService parameter for this call.</td>
 </tr></tbody></table>
</dd></dl><p>The client MAY provide a combination of one or more
SECURITY_INFORMATION bit flags for <i>dwSecurityInformation</i>.</p><p>If SACL_SECURITY_INFORMATION is specified via <i>dwSecurityInformation</i>,
then an ACCESS_SYSTEM_SECURITY right MUSThave been granted to the caller when <i>hService</i>
was created. (See WD in ACCESS_MASK in <span><a href="../ms-dtyp/cca27429-5689-4a16-b2b4-9325d93e4ba2" data-linktype="relative-path">[MS-DTYP]</a></span>
<span><a href="../ms-dtyp/7a53f60e-e730-4dfe-bbe9-b21b62eb790b" data-linktype="relative-path">2.4.3</a></span>.</p><p>If LABEL_SECURITY_INFORMATION or OWNER_SECURITY_INFORMATION
or GROUP_SECURITY_INFORMATION is specified via <i>dwSecurityInformation</i>,
then a WRITE_OWNER right MUST have been granted to the caller when <i>hService</i>
was created. (See WO in ACCESS_MASK in [MS-DTYP] 2.4.3.)</p><p>If DACL_SECURITY_INFORMATION is specified via <i>dwSecurityInformation</i>,
then a WRITE_DAC right MUST have been granted to the caller when <i>hService</i>
was created. (See WD in ACCESS_MASK in [MS-DTYP] 2.4.3.)</p><p>In response to this request from the client, for a
successful operation the server MUST apply the information from the
SECURITY_DESCRIPTOR structure specified in the <i>lpSecurityDescriptor</i>
parameter to the SecurityDescriptor associated with the SCM or the service
record identified by the <i>hService</i> parameter of the request.</p></div>