Samba 独立服务器使用 LDAP 进行身份验证:SID 不匹配

Samba 独立服务器使用 LDAP 进行身份验证:SID 不匹配

我已经尝试运行我的新 samba 服务器好几天了,我开始因为不知道我做错了什么而发疯。这是我的设置:

OpenLDAP 2.4.21 服务器具有大约 15 个组和超过 100 个用户,所有用户都有一个 unix 和一个 samba 密码存储在 LDAP 中,并且分配并存储在 LDAP 中的用户 SID 和主组 SID(源自 LDAP 服务器的 SID)。

现在我想使用多个 samba 服务器来使用 LDAP 服务器对用户进行身份验证。samba 服务器是使用 ldap 服务器配置了 NSS/PAM 的 Linux。getent passwd/group 返回所有用户,并且 ssh 到 samba 机器适用于所有用户。现在这是 smb.conf:

[global]
workgroup = XXXXX
security = user
passdb backend = ldapsam:ldap://myldapserver
ldap suffix = dc=mydomain,dc=com
ldap admin dn = cn=replicator,dc=mydomain,dc=com
ldap user suffix = ou=users
ldap group suffix = ou=groups
ldap machine suffix = ou=computers
ldap ssl = start tls

ldap 连接成功,如下pdbedit -L图所示

pm_process() returned Yes
smbldap_search_domain_info: Searching for:[(&(objectClass=sambaDomain)(sambaDomainName=SAMBAHOSTNAME))]
StartTLS issued: using a TLS connection
smbldap_open_connection: connection opened
ldap_connect_system: successful connection to the LDAP server
The LDAP server is successfully connected
smbldap_search_paged: base => [dc=mydomain,dc=com], filter => [(&(uid=*)(objectclass=sambaSamAccount))],scope => [2], pagesize => [1024]
smbldap_search_paged: search was successful
sid S-1-5-21-[LDAPSID]-5168 does not belong to our domain

然后最后一条消息对所有 uid 重复。使用smbclient -L localhost -U someid日志文件显示:

check_ntlm_password:  Checking password for unmapped user [XXX]\[someid]@[SAMBAHOST] with the new password interface
check_ntlm_password:  mapped user is: [SAMBAHOST]\[someid]@[SAMBAHOST]
StartTLS issued: using a TLS connection
smbldap_open_connection: connection opened
ldap_connect_system: successful connection to the LDAP server
The LDAP server is successfully connected
init_sam_from_ldap: Entry found for user: someid
Home server: SAMBAHOST
Home server: SAMBAHOST
init_group_from_ldap: Entry found for group: 1011
init_group_from_ldap: Entry found for group: 1011
Primary group S-1-5-21-[LDAPSID]-1000 for user someid is a UNKNOWN and not a domain group
Forcing Primary Group to 'Domain Users' for someid
ntlm_password_check: Checking NTLMv2 password with domain [CIN]
sam_account_ok: Checking SMB password for user someid
The primary group domain sid(S-1-5-21-[LOCALSID]-513) does not match the domain sid(S-1-5-21-[LDAPSID]) for someid(S-1-5-21-[LDAPSID]-5708)
check_sam_security: make_server_info_sam() failed with 'NT_STATUS_UNSUCCESSFUL'
check_ntlm_password:  Authentication for user [someid] -> [someid] FAILED with error NT_STATUS_UNSUCCESSFUL

我在这里看到的是,samba 服务器无法识别用户的主要组(这是 LDAP 中的现有组),因此将主要组映射到其本地“域用户”组,这显然与用户 ID 的域 SID 不匹配。但是为什么 samba 服务器无法识别该组?还是存在其他潜在问题?

我到目前为止尝试过的:

将 samba 服务器的 SID 更改为 LDAP 服务器的 SID,但未net setlocalsid S-...更改本地 SID。没有错误消息,只是成功执行,但 getlocalsid 返回了旧的 SID。

将 samba 服务器的 domainsid 设置为 ldap 服务器的 SID。net setdomainsid S-...已成功,但 samba 服务器仍然拒绝对用户进行身份验证。

尝试将服务器添加到域,net join XXX但答案只是“独立服务器无法加入域”。

我尝试运行smbpasswd -a将用户添加到本地 samba db(尽管这不是最终解决方案的选项,但这是其他用户推荐的),但错误并没有改变。

我该如何告诉 Samba 忽略域 SID 不匹配或强制 Samba 与 LDAP 具有相同的 SID?或者,如果 ~10 Samba 服务器和 LDAP 最终都具有完全相同的 SID,这是否会导致其他问题?

答案1

我遇到了类似的问题。我必须编辑 LDAP 中域、用户和组的 sambaSID 条目,以便它们与我的服务器相匹配。否则,您将在服务器的 Samba 日志中收到以下错误消息。要查看此日志,请确保log level = 2在您的smb.conf.:

[2015/12/03 14:39:19.753690,  1] ../source3/auth/server_info.c:346(samu_to_SamInfo3)
  The primary group domain sid(S-1-5-21-748580849-194208185-3916830000-513) does not match the domain sid(S-1-5-21-2566626306-4294080665-3504248766) for someuser(S-1-5-21-2566626306-4294080665-3504248766-11678)
[2015/12/03 14:39:19.753733,  0] ../source3/auth/check_samsec.c:492(check_sam_security)
  check_sam_security: make_server_info_sam() failed with 'NT_STATUS_UNSUCCESSFUL'
[2015/12/03 14:39:19.753755,  2] ../source3/auth/auth.c:288(auth_check_ntlm_password)
  check_ntlm_password:  Authentication for user [someuser] -> [bbogaert] FAILED with error NT_STATUS_UNSUCCESSFUL
[2015/12/03 14:39:19.753777,  2] ../auth/gensec/spnego.c:743(gensec_spnego_server_negTokenTarg)
  SPNEGO login failed: NT_STATUS_UNSUCCESSFUL

在您的服务器上运行net getdomainsid。这将返回localsiddomainsid这些值应该匹配. 如果它们没有达到net setdomainsid的值SID for local machine

root@TheWiggle:~# net getdomainsid
SID for local machine THEWIGGLE is: S-1-5-21-748580849-194208185-3916830000
SID for domain THISDOMAIN is: S-1-5-21-748580849-194208185-3916830000

现在在您的 LDAP 服务器上获取 的值并确保这是的SID for domain属性值。sambaSIDsambaDomainName=THISDOMAIN

还要确保用户的sambaSID和以及组的由和属性的唯一值组成。sambaPrimaryGroupIDsambaSIDSID for domain

例如,sambaSIDsomeuser将是S-1-5-21-748580849-194208185-3916830000-99999,其 sambaPrimaryGroupID 将是S-1-5-21-748580849-194208185-3916830000-555sambaSID组的 将是S-1-5-21-748580849-194208185-3916830000-77777

希望这可以帮助!!!

相关内容