Skip to content

Commit

Permalink
tests/bind.py: Add a bind test with NTLMSSP with no domain
Browse files Browse the repository at this point in the history
Confirmed to pass against Windows 2012 R2.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13206

Signed-off-by: Garming Sam <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
GSam authored and abartlet committed Feb 22, 2018
1 parent 5c625ea commit 2e49a97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion auth/credentials/tests/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
creds_user1 = copy.deepcopy(creds)
creds_user2 = copy.deepcopy(creds)
creds_user3 = copy.deepcopy(creds)
creds_user4 = copy.deepcopy(creds)

class BindTests(samba.tests.TestCase):

Expand All @@ -64,7 +65,7 @@ def setUp(self):
self.config_dn = self.info_dc["configurationNamingContext"][0]
self.computer_dn = "CN=centos53,CN=Computers,%s" % self.domain_dn
self.password = "P@ssw0rd"
self.username = "BindTestUser_" + time.strftime("%s", time.gmtime())
self.username = "BindTestUser"

def tearDown(self):
super(BindTests, self).tearDown()
Expand Down Expand Up @@ -113,6 +114,7 @@ def test_user_account_bind(self):
expression="(samAccountName=%s)" % self.username)
self.assertEquals(len(ldb_res), 1)
user_dn = ldb_res[0]["dn"]
self.addCleanup(delete_force, self.ldb, user_dn)

# do a simple bind and search with the user account in format user@realm
creds_user1.set_bind_dn(self.username + "@" + creds.get_realm())
Expand All @@ -138,5 +140,27 @@ def test_user_account_bind(self):
lp=lp, ldap_only=True)
res = ldb_user3.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)
ldb_res = self.ldb.search(base=self.domain_dn,
scope=SCOPE_SUBTREE,
expression="(samAccountName=%s)" % self.username)
self.assertEquals(len(ldb_res), 1)
user_dn = ldb_res[0]["dn"]
self.addCleanup(delete_force, self.ldb, user_dn)

creds_user4.set_username(self.username)
creds_user4.set_password(self.password)
creds_user4.set_domain('')
creds_user4.set_workstation('')
print "BindTest (no domain) with: " + self.username
try:
ldb_user4 = samba.tests.connect_samdb(host, credentials=creds_user4,
lp=lp, ldap_only=True)
except:
self.fail("Failed to connect without the domain set")

res = ldb_user4.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])

TestProgram(module=__name__, opts=subunitopts)
1 change: 1 addition & 0 deletions selftest/knownfail.d/empty-domain-bind
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^samba4.ldap.bind\(fl2008r2dc\).__main__.BindTests.test_user_account_bind_no_domain.*

0 comments on commit 2e49a97

Please sign in to comment.