Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had the same question, and I believe the right answer is:</p> <p>SID as string: 184 characters, or varchar(184) in SQL Server</p> <p>SID as string of Hex digits: 136 characters, or varchar(136) in SQL Server</p> <p>SID as binary: 68 bytes, or varbinary(68) in SQL Server</p> <p>I haven't checked the math myself, but the technique used here looks valid: <a href="https://groups.google.com/d/msg/microsoft.public.dotnet.security/NpIi7c2Toi8/31SVhcepY58J" rel="noreferrer">https://groups.google.com/d/msg/microsoft.public.dotnet.security/NpIi7c2Toi8/31SVhcepY58J</a></p> <p>Refer to the program written by Russell Mangel on Aug 19, 2006, also copied here for reference:</p> <blockquote> <p>So the answer to my question is:</p> <p>varbinary(68)-- pure binary varchar(136) -- (68*2) = hexString varchar(184) -- SID String</p> <p>I wrote a little program to test, notice that .NET 2.0 has SecurityIdentifier.MaxBinaryLength, I didn't know about this.</p> <pre><code>Console.WriteLine("SID Min. num Bytes: {0}", SecurityIdentifier.MinBinaryLength); Console.WriteLine("SID Min. num Bytes: {0}", SecurityIdentifier.MaxBinaryLength); Byte[] bytes = new byte[SecurityIdentifier.MaxBinaryLength]; for (Int32 i = 0; i &lt; bytes.Length; i++) { bytes[i] = 0xFF; } bytes[0] = 0x01; // Must be 1 bytes[1] = 0x0F; // Max 15 (base10) SecurityIdentifier sid = new SecurityIdentifier(bytes, 0); String sidString = sid.ToString(); Console.WriteLine("Max length of SID in String format: {0} ", sidString.Length); Console.WriteLine(sidString); </code></pre> <p>Results ------------------------------</p> <p>SID Min. num Bytes: 8 SID Min. num Bytes: 68 Max length of SID in String format: 184 S-1-281474976710655-4294967295-4294967295-4294967295-4294967295-4294967295- 4294967295-4294967295-4294967295-4294967295-4294967295-4294967295 -4294967295-4294967295-4294967295-4294967295</p> <hr> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload