SDDL 格式的 SID 的最大长度是多少
我正在将 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我有同样的问题,我相信正确的答案是:
我自己没有检查过数学,但这里使用的技术看起来是有效的:
https://groups.google.com/d/msg /microsoft.public.dotnet.security/NpIi7c2Toi8/31SVhcepY58J
参考Russell Mangel于2006年8月19日编写的程序,也复制在此供参考:
I had the same question, and I believe the right answer is:
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
Refer to the program written by Russell Mangel on Aug 19, 2006, also copied here for reference:
根据 ntseapi_x.h:
UCHAR 实际上是一个 unsigned char,它是 1 个字节。 ULONG 是一个 unsigned long,大小为 4 个字节。
SID 的最大数据大小为 68 字节: UCHAR + UCHAR + (UCHAR * 6) + (ULONG * 15) = 1 + 1 + 6 + 60 = 68
将 SID 转换为字符串,就像您一样将通过调用 ConvertSidToStringSid 获得,可能看起来像这样: L"S-1-5-21-66"
SID 的最大字符串长度为 184: 3 + 1 + 14 + 1 + (10 * 15) + 14 = 183,或 184 计算空值。
您可以考虑仅使用 MAX_UNICODE_STACK_BUFFER_LENGTH 或 256,它们非常适合内存。
According to ntseapi_x.h:
A UCHAR is actually an unsigned char which is 1 byte. ULONG is an unsigned long which is 4 bytes.
SID's max data size is 68 bytes: UCHAR + UCHAR + (UCHAR * 6) + (ULONG * 15) = 1 + 1 + 6 + 60 = 68
Converting a SID to a string, like what you would get by calling ConvertSidToStringSid, might look something like this: L"S-1-5-21-66"
SID's max string length is 184: 3 + 1 + 14 + 1 + (10 * 15) + 14 = 183, or 184 counting the null.
You may consider just using MAX_UNICODE_STACK_BUFFER_LENGTH or 256 which fits nicely in memory.
虽然 184 看起来是正确的,但在官方文档中有一个不同的值:
https://learn.microsoft.com/en-us/windows-hardware/customize/桌面/无人参与/microsoft-windows-shell-setup-offlineuseraccounts-offlinedomainaccounts-offlinedomainaccount-sid#:~:text=SID%20is%20a%20string%20with%20a%20maximum%20length%20of%20256%20characters 。
While 184 looks correct, on the official docs there is a different value:
https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-offlineuseraccounts-offlinedomainaccounts-offlinedomainaccount-sid#:~:text=SID%20is%20a%20string%20with%20a%20maximum%20length%20of%20256%20characters.