Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

CreateWellKnownSid (advapi32)
 
.
Summary
Creates a SID for predefined aliases

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
static extern bool CreateWellKnownSid(
    WELL_KNOWN_SID_TYPE WellKnownSidType,
    IntPtr DomainSid
    IntPtr pSid,
    ref uint cbSid);

User-Defined Types:

WELL_KNOWN_SID_TYPE

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

  string GetWellKnownSID(WELL_KNOWN_SID_TYPE wellKnownSidType)
  {
      IntPtr domainSid = IntPtr.Zero;
      IntPtr pSid = IntPtr.Zero;
      uint cbSid = 0;
      string sidString = string.Empty;

      NativeMethods.CreateWellKnownSid(wellKnownSidType, domainSid, pSid, ref cbSid);

      pSid = Marshal.AllocCoTaskMem(Convert.ToInt32(cbSid));
      if (NativeMethods.CreateWellKnownSid(wellKnownSidType, domainSid, pSid, ref cbSid))
      {
      NativeMethods.ConvertSidToStringSid(pSid, out sidString);
      }

      Marshal.FreeCoTaskMem(pSid);

      return sidString;
  }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions