Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
private static ManagementObject Win32_Trustee(string Account)
{
byte[] SID = null;
ManagementObjectCollection UserSearch =
new ManagementObjectSearcher("Select * From Win32_Account Where Name = '" + Account + "'").Get();
try
{
foreach(ManagementObject UserObject in UserSearch)
{
IntPtr SID_ptr=new IntPtr(0);
ConvertStringSidToSid(UserObject["SID"].ToString(), out SID_ptr);
int size = (int)GetLengthSid(SID_ptr);
SID = new byte[size];
Marshal.Copy(SID_ptr, SID, 0, size);
Marshal.FreeHGlobal(SID_ptr);
}
}
catch (Exception se)
{
Trace.WriteLine(se.Message);
}
ManagementObject Trustee = new System.Management.ManagementClass("Win32_Trustee").CreateInstance();
Trustee["SID"] = SID;
return Trustee;
}
}
Alternative Managed API:
The ConvertStringSidToSid function converts a string-format SID into a valid, functional SID. You can use this function to retrieve a SID that the ConvertSidToStringSid function converted to string format.
10/9/2019 12:34:03 PM - Hi-79.202.51.48
The ConvertSidToStringSid function converts a security identifier (SID) to a string format suitable for display, storage, or transmission.
9/9/2022 3:59:14 AM - -14.140.20.18
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).