]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
auth/credentials: Add test for binding with a domain SID
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 30 Mar 2021 00:28:32 +0000 (13:28 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 7 Apr 2021 09:18:30 +0000 (09:18 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10319

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
auth/credentials/tests/bind.py
selftest/knownfail.d/bug-10319 [new file with mode: 0644]

index 8bee6f96c62a43d90e42a3e64fabb69ad326cf19..b26be4f0f79e7e13539bbc93f7958f08b585dc10 100755 (executable)
@@ -53,6 +53,7 @@ creds_user1 = create_credential(lp, creds)
 creds_user2 = create_credential(lp, creds)
 creds_user3 = create_credential(lp, creds)
 creds_user4 = create_credential(lp, creds)
+creds_user5 = create_credential(lp, creds)
 
 class BindTests(samba.tests.TestCase):
 
@@ -169,7 +170,8 @@ unicodePwd:: """ + base64.b64encode(u"\"P@ssw0rd\"".encode('utf-16-le')).decode(
         self.ldb.newuser(username=self.username, password=self.password)
         ldb_res = self.ldb.search(base=self.domain_dn,
                                   scope=SCOPE_SUBTREE,
-                                  expression="(samAccountName=%s)" % self.username)
+                                  expression="(samAccountName=%s)" % self.username,
+                                  attrs=["objectSid"])
         self.assertEqual(len(ldb_res), 1)
         user_dn = ldb_res[0]["dn"]
         self.addCleanup(delete_force, self.ldb, user_dn)
@@ -198,6 +200,17 @@ unicodePwd:: """ + base64.b64encode(u"\"P@ssw0rd\"".encode('utf-16-le')).decode(
                                               lp=lp, ldap_only=True)
         res = ldb_user3.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
 
+        # do a simple bind and search with the user account SID
+        creds_user5.set_bind_dn(self.ldb.schema_format_value("objectSid", ldb_res[0]["objectSid"][0]).decode('utf8'))
+        creds_user5.set_password(self.password)
+        print("BindTest with: " + creds_user5.get_bind_dn())
+        try:
+            ldb_user5 = samba.tests.connect_samdb(host, credentials=creds_user5,
+                                                  lp=lp, ldap_only=True)
+        except:
+            self.fail("Failed to connect with user account SID")
+        res = ldb_user5.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
+
     def test_user_account_bind_no_domain(self):
         # create user
         self.ldb.newuser(username=self.username, password=self.password)
diff --git a/selftest/knownfail.d/bug-10319 b/selftest/knownfail.d/bug-10319
new file mode 100644 (file)
index 0000000..0218e6b
--- /dev/null
@@ -0,0 +1 @@
+^samba4.ldap.bind\(fl2008r2dc\).__main__.BindTests.test_user_account_bind\(fl2008r2dc\)