Skip to content

Commit 5752e4e

Browse files
committed
Handle the case that sambaSID doesn't exist for OpenLDAP posix schema, and I
think we're supposed to set use_rid to tell the difference.
1 parent 8b9f90d commit 5752e4e

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

Diff for: nss_cache/sources/ldapsource_test.py

+40-13
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def testGetPasswdMap(self):
250250
config = dict(self.config)
251251
attrlist = [
252252
'uid', 'uidNumber', 'gidNumber', 'gecos', 'cn', 'homeDirectory',
253-
'sambaSID', 'fullName', 'loginShell', 'modifyTimestamp'
253+
'fullName', 'loginShell', 'modifyTimestamp'
254254
]
255255

256256
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
@@ -302,7 +302,7 @@ def testGetPasswdMapWithUidAttr(self):
302302
config['uidattr'] = 'name'
303303
attrlist = [
304304
'uid', 'uidNumber', 'gidNumber', 'gecos', 'cn', 'homeDirectory',
305-
'fullName', 'name', 'sambaSID', 'loginShell', 'modifyTimestamp'
305+
'fullName', 'name', 'loginShell', 'modifyTimestamp'
306306
]
307307

308308
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
@@ -353,7 +353,7 @@ def testGetPasswdMapWithShellOverride(self):
353353
config['override_shell'] = '/bin/false'
354354
attrlist = [
355355
'uid', 'uidNumber', 'gidNumber', 'gecos', 'cn', 'homeDirectory',
356-
'fullName', 'sambaSID', 'loginShell', 'modifyTimestamp'
356+
'fullName', 'loginShell', 'modifyTimestamp'
357357
]
358358

359359
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
@@ -551,9 +551,7 @@ def testGetGroupMap(self):
551551
})
552552

553553
config = dict(self.config)
554-
attrlist = [
555-
'cn', 'uid', 'gidNumber', 'memberUid', 'sambaSID', 'modifyTimestamp'
556-
]
554+
attrlist = ['cn', 'uid', 'gidNumber', 'memberUid', 'modifyTimestamp']
557555

558556
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
559557
mock_rlo.simple_bind_s(cred='TEST_BIND_PASSWORD', who='TEST_BIND_DN')
@@ -747,9 +745,7 @@ def testGetGroupMapBis(self):
747745

748746
config = dict(self.config)
749747
config['rfc2307bis'] = 1
750-
attrlist = [
751-
'cn', 'uid', 'gidNumber', 'member', 'sambaSID', 'modifyTimestamp'
752-
]
748+
attrlist = ['cn', 'uid', 'gidNumber', 'member', 'modifyTimestamp']
753749

754750
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
755751
mock_rlo.simple_bind_s(cred='TEST_BIND_PASSWORD', who='TEST_BIND_DN')
@@ -810,9 +806,7 @@ def testGetGroupNestedNotConfigured(self):
810806

811807
config = dict(self.config)
812808
config['rfc2307bis'] = 1
813-
attrlist = [
814-
'cn', 'uid', 'gidNumber', 'member', 'sambaSID', 'modifyTimestamp'
815-
]
809+
attrlist = ['cn', 'uid', 'gidNumber', 'member', 'modifyTimestamp']
816810

817811
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
818812
mock_rlo.simple_bind_s(cred='TEST_BIND_PASSWORD', who='TEST_BIND_DN')
@@ -875,6 +869,7 @@ def testGetGroupNested(self):
875869
config = dict(self.config)
876870
config['rfc2307bis'] = 1
877871
config["nested_groups"] = 1
872+
config['use_rid'] = 1
878873
attrlist = [
879874
'cn', 'uid', 'gidNumber', 'member', 'sambaSID', 'modifyTimestamp'
880875
]
@@ -950,6 +945,7 @@ def testGetGroupLoop(self):
950945
config = dict(self.config)
951946
config['rfc2307bis'] = 1
952947
config["nested_groups"] = 1
948+
config['use_rid'] = 1
953949
attrlist = [
954950
'cn', 'uid', 'gidNumber', 'member', 'sambaSID', 'modifyTimestamp'
955951
]
@@ -1010,6 +1006,7 @@ def testGetGroupMapBisAlt(self):
10101006

10111007
config = dict(self.config)
10121008
config['rfc2307bis_alt'] = 1
1009+
config['use_rid'] = 1
10131010
attrlist = [
10141011
'cn', 'gidNumber', 'uniqueMember', 'uid', 'sambaSID',
10151012
'modifyTimestamp'
@@ -1366,7 +1363,7 @@ def testGetAutomountMasterMap(self):
13661363
def testVerify(self):
13671364
attrlist = [
13681365
'uid', 'uidNumber', 'gidNumber', 'gecos', 'cn', 'homeDirectory',
1369-
'fullName', 'sambaSID', 'loginShell', 'modifyTimestamp'
1366+
'fullName', 'loginShell', 'modifyTimestamp'
13701367
]
13711368
filterstr = '(&TEST_FILTER(modifyTimestamp>=19700101000001Z))'
13721369

@@ -1391,6 +1388,36 @@ def testVerify(self):
13911388
source = ldapsource.LdapSource(self.config)
13921389
self.assertEqual(0, source.Verify(0))
13931390

1391+
def testVerifyRID(self):
1392+
attrlist = [
1393+
'uid', 'uidNumber', 'gidNumber', 'gecos', 'cn', 'homeDirectory',
1394+
'fullName', 'loginShell', 'modifyTimestamp', 'sambaSID'
1395+
]
1396+
filterstr = '(&TEST_FILTER(modifyTimestamp>=19700101000001Z))'
1397+
1398+
mock_rlo = self.mox.CreateMock(ldap.ldapobject.ReconnectLDAPObject)
1399+
mock_rlo.simple_bind_s(cred='TEST_BIND_PASSWORD', who='TEST_BIND_DN')
1400+
mock_rlo.search_ext(base='TEST_BASE',
1401+
filterstr=filterstr,
1402+
scope=ldap.SCOPE_ONELEVEL,
1403+
attrlist=mox.SameElementsAs(attrlist),
1404+
serverctrls=mox.Func(
1405+
self.compareSPRC())).AndReturn('TEST_RES')
1406+
1407+
mock_rlo.result3('TEST_RES', all=0, timeout='TEST_TIMELIMIT').AndReturn(
1408+
(ldap.RES_SEARCH_RESULT, None, None, []))
1409+
self.mox.StubOutWithMock(ldap, 'ldapobject')
1410+
ldap.ldapobject.ReconnectLDAPObject(
1411+
uri='TEST_URI',
1412+
retry_max=TEST_RETRY_MAX,
1413+
retry_delay=TEST_RETRY_DELAY).AndReturn(mock_rlo)
1414+
1415+
config = dict(self.config)
1416+
config['use_rid'] = 1
1417+
self.mox.ReplayAll()
1418+
source = ldapsource.LdapSource(config)
1419+
self.assertEqual(0, source.Verify(0))
1420+
13941421

13951422
class TestUpdateGetter(unittest.TestCase):
13961423

Diff for: nsscache.conf

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ldap_filter = (objectclass=posixAccount)
8989
# If connecting to openldap, uidNumber and gidNumber
9090
# will be used for mapping. If enabled (set to 1),
9191
# the relative identifier (RID) will be used instead.
92+
# Consider using this for Samba4 AD.
9293
#ldap_use_rid = 0
9394

9495
# Default Offset option to map uidNumber and gidNumber to higher number.

Diff for: nsscache.conf.5

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ is the default). See \fBldap.conf\fP(5) for more information.
159159

160160
.TP
161161
.B ldap_tls_cacertdir
162-
Directory for trusted CA certificates. By default, the system's
162+
Directory for trusted CA certificates. By default, the system\'s
163163
default CA certificate directory will be used.
164164

165165
.TP
@@ -188,7 +188,8 @@ The uid-like attribute in your directory. Defaults to uid.
188188
.TP
189189
.B ldap_use_rid
190190
If enabled (set to 1) the relative identifier (RID) wll be used for mapping.
191-
By default uidNumber and gidNumber will be mapped when connectin to OpenLdap.
191+
By default \fBuidNumber\fP and \fBgidNumber\fP will be mapped when connecting to OpenLDAP with a POSIX-like schema.
192+
When using Samba4 AD, these attributes won\'t exist.
192193
Leave disabled for default.
193194
It has no effect if the option \fBldap_ad\fP is enabled.
194195

0 commit comments

Comments
 (0)