title: How to call the AllocateAndInitializeSid function from C#?
body: <p>Can somebody give me a complete and working example of calling the <code>AllocateAndInitializeSid</code> function from C# code?</p>
  
  <p>I found <a href="http://msdn.microsoft.com/en-us/library/aa375213(VS.85).aspx" rel="nofollow noreferrer">this</a>:  </p>
  
  <pre><code>BOOL WINAPI AllocateAndInitializeSid(
    __in   PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
    __in   BYTE nSubAuthorityCount,
    __in   DWORD dwSubAuthority0,
    __in   DWORD dwSubAuthority1,
    __in   DWORD dwSubAuthority2,
    __in   DWORD dwSubAuthority3,
    __in   DWORD dwSubAuthority4,
    __in   DWORD dwSubAuthority5,
    __in   DWORD dwSubAuthority6,
    __in   DWORD dwSubAuthority7,
    __out  PSID *pSid
  );
  </code></pre>
  
  <p>and I don't know how to construct the signature of this method - what should I do with <code>PSID_IDENTIFIER_AUTHORITY</code> and <code>PSID</code> types? How should I pass them - using <code>ref</code> or <code>out</code>?</p>