大网数据广告活动
服务器运维问答

Background on sambaSID calculation

· 52CE 我爱测

I am contributing to, and running an open source web application that, in large parts, existed before my time. The application adds LDAP entries for web application users to a local LDAP instance to give these users file system a…

问题原文

原帖链接 · Matthias Ronge · CC BY-SA 3.0

I am contributing to, and running an open source web application that, in large parts, existed before my time. The application adds LDAP entries for web application users to a local LDAP instance to give these users file system access via Samba.

In all working examples I know of the sambaSID value stored in LDAP is configured to be calculated by the pattern

$LOCALSID "-" ($UIDNUMBER * 2 + 1000)

Example: for a user with uid 1002 the sambaSID will be something like S-1-5-21-1234567890-5678912345-987654321 - 3004 [spaces added for readability]. I am curious of why this is necessary. Where do these magic numbers 2 and 1000 come from, are they necessary, and if so, why?

Searching around, I found this PDF which is unrelated to our application and explains exactly this procedure:

5. Setting up user sambaSIDs

When creating users for the external LDAP, you need to pay special attention to their sambaSIDs.

Correct Samba entries for a user look like the following example:

uidNumber: 1001

sambaSID: S-1-5-21-2896602268-470177729-4123194723-3002
gidNumber: 1000

sambaPrimaryGroupSID: S-1-5-21-2896602268-470177729-4123194723-3001

As you can see, there is a 4-digit number appended to the regular sambaSID (which is taken from the WORKGROUP example above). This is generated in the following manner:

sambaSID: uidNumber * 2 + 1000
sambaPrimaryGroupSID: gidNumber * 2 + 1001

These entries must always match and conform to the schema above – otherwise the user will not be able to connect via SMB.

So it does not seem to be the case that these numbers are chosen arbitrarily. However, in our examples, unlike in the PDF cited, I find that the sambaPrimaryGroupSID does not undergo any artithmetics, its value for group 100 (users) it is just appended, like S-1-5-21-1234567890-5678912345-987654321 - 100, which is different from the explainations in the PDF cited above. However, the Samba access works properly with it, too, so I wonder how reliable the source I found is.

What are those magic numbers ‘2’ and ‘1000’ come from? Are they necessary or useful for anything?

已采纳解答

原帖链接 · student91 · CC BY-SA 4.0

I was searching for the same thing, and found this link.

There it is explained that the multiplication with 2 is to make sure user-secure-IDs and group-secure-IDs do not overlap. (The latter always being odd).

About the +1000, numbers below 1000 are reserved for special Windows groups, just as in Linux quite a lot of smaller group-numbers are reserved. Regular Windows users get numbers starting with 1000.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。