什么是一个SID的以SDDL格式的最大长度 [英] What is the maximum length of a SID in SDDL format

查看:313
本文介绍了什么是一个SID的以SDDL格式的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建Active Directory验证了我的申请,我打算给我的应用程序的内部帐户链接到用户的域SID。这是我更容易与SID不是一个字节数组的字符串格式工作,所以我打算将其存储在数据库中的字符串。多久我应该做的领域,以确保SID的将不被截断?

I'm building Active Directory Authentication into my application and I am planning to link my application's internal accounts to a user's domain SID. It is easier for me to work with the string format of the sid than a byte array so I was planning to store it in the database as a string. How long should I make the field to ensure SID's will not get truncated?

推荐答案

我有同样的问题,我认为正确的答案是:

I had the same question, and I believe the right answer is:

SID为字符串:184个字符,或varchar(184)在SQL Server

SID as string: 184 characters, or varchar(184) in SQL Server

SID为字符串的十六进制数字:136个字符,或varchar(136)在SQL Server

SID as string of Hex digits: 136 characters, or varchar(136) in SQL Server

SID为二进制:68字节,或varbinary(68)在SQL Server

SID as binary: 68 bytes, or varbinary(68) in SQL Server

我没有检查算算自己,但这里所使用的技术看起来有效的: 的https://groups.google.com/d/msg/microsoft.public.dotnet.security/NpIi7c2Toi8/31SVhcepY58J

I haven't checked the math myself, but the technique used here looks valid: https://groups.google.com/d/msg/microsoft.public.dotnet.security/NpIi7c2Toi8/31SVhcepY58J

请参阅有关2006年8月19日写的罗素甜菜程序,也复制在这里,以供参考:

Refer to the program written by Russell Mangel on Aug 19, 2006, also copied here for reference:

所以,回答我的问题是:

So the answer to my question is:

VARBINARY(68) - 纯二进制   VARCHAR(136) - (68 * 2)=十六进制串   VARCHAR(184) - SID字符串

varbinary(68)-- pure binary varchar(136) -- (68*2) = hexString varchar(184) -- SID String

我写了一个小程序来测试,   请注意,.NET 2.0有   SecurityIdentifier.MaxBinaryLength,我   不知道这一点。

I wrote a little program to test, notice that .NET 2.0 has SecurityIdentifier.MaxBinaryLength, I didn't know about this.

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 < 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);

     

结果------------------------------

Results ------------------------------

SID最小。 NUM字节:8   SID最小。 NUM字节:68   SID的字符串格式最大长度:184   S-1-281474976710655-4294967295-4294967295-4294967295-4294967295-4294967295-   4294967295-4294967295-4294967295-4294967295-4294967295-4294967295   -4294967295-4294967295-4294967295-4294967295

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

这篇关于什么是一个SID的以SDDL格式的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆