[SCM] Samba Shared Repository - branch master updated
Nadezhda Ivanova
nivanova at samba.org
Tue Nov 23 03:09:01 MST 2010
The branch, master has been updated
via 439ff87 s4-tests: Ldap tests now use the get_dsheuristics and set_dsheuristics from SamDB.
via c252dac s4-tests: Password tests now use the get_dsheuristics and set_dsheuristics from SamDB.
via d6679cb s4-tests: Acl tests now use the get_dsheuristics and set_dsheuristics from SamDB.
via eaa9733 s4-dsdb: Added python helpers for getting and seting dSHeuristics to SamDB
from 95edbc3 wintest Evolve wintest to handle it's own BIND nameserver
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 439ff8717d41fb641f2a2cf2b14665edf375433d
Author: Nadezhda Ivanova <nivanova at samba.org>
Date: Tue Nov 23 11:22:10 2010 +0200
s4-tests: Ldap tests now use the get_dsheuristics and set_dsheuristics from SamDB.
Autobuild-User: Nadezhda Ivanova <nivanova at samba.org>
Autobuild-Date: Tue Nov 23 11:08:37 CET 2010 on sn-devel-104
commit c252dac1b3263361ddac87e782c2230679f22589
Author: Nadezhda Ivanova <nivanova at samba.org>
Date: Tue Nov 23 11:21:47 2010 +0200
s4-tests: Password tests now use the get_dsheuristics and set_dsheuristics from SamDB.
commit d6679cb75a68b85c5dc28b5633bead84cc2deba9
Author: Nadezhda Ivanova <nivanova at samba.org>
Date: Tue Nov 23 11:21:22 2010 +0200
s4-tests: Acl tests now use the get_dsheuristics and set_dsheuristics from SamDB.
commit eaa9733a83b23da8c54cc2975c4ff3c854bbc30f
Author: Nadezhda Ivanova <nivanova at samba.org>
Date: Tue Nov 23 11:20:12 2010 +0200
s4-dsdb: Added python helpers for getting and seting dSHeuristics to SamDB
-----------------------------------------------------------------------
Summary of changes:
source4/dsdb/tests/python/acl.py | 30 ++++-------------
source4/dsdb/tests/python/ldap.py | 31 +++--------------
source4/dsdb/tests/python/passwords.py | 53 +++++-------------------------
source4/scripting/python/samba/samdb.py | 24 ++++++++++++++
4 files changed, 46 insertions(+), 92 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py
index 8a1c6a4..2b805d6 100755
--- a/source4/dsdb/tests/python/acl.py
+++ b/source4/dsdb/tests/python/acl.py
@@ -221,17 +221,6 @@ url: www.example.com
self.create_active_user(self.ldb_admin, self.get_user_dn(username))
self.ldb_admin.enable_account("(sAMAccountName=" + username + ")")
- def set_dsheuristics(self, dsheuristics):
- m = Message()
- m.dn = Dn(self.ldb_admin, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + self.configuration_dn)
- if dsheuristics is not None:
- m["dSHeuristics"] = MessageElement(dsheuristics, FLAG_MOD_REPLACE,
- "dSHeuristics")
- else:
- m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics")
- self.ldb_admin.modify(m)
-
#tests on ldap add operations
class AclAddTests(AclTests):
@@ -697,13 +686,8 @@ class AclSearchTests(AclTests):
self.creds_tmp.set_domain(creds.get_domain())
self.creds_tmp.set_realm(creds.get_realm())
self.creds_tmp.set_workstation(creds.get_workstation())
- self.anonymous = SamDB(url=host, credentials=self.creds_tmp, lp=lp);
- res = self.ldb_admin.search("CN=Directory Service, CN=Windows NT, CN=Services, "
- + self.configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"])
- if "dSHeuristics" in res[0]:
- self.dsheuristics = res[0]["dSHeuristics"][0]
- else:
- self.dsheuristics = None
+ self.anonymous = SamDB(url=host, credentials=self.creds_tmp, lp=lp)
+ self.dsheuristics = self.ldb_admin.get_dsheuristics()
self.create_enable_user(self.u1)
self.create_enable_user(self.u2)
self.create_enable_user(self.u3)
@@ -801,7 +785,7 @@ class AclSearchTests(AclTests):
def test_search_anonymous3(self):
"""Set dsHeuristics and repeat"""
- self.set_dsheuristics("0000002")
+ self.ldb_admin.set_dsheuristics("0000002")
self.create_ou(self.ldb_admin, "OU=test_search_ou1," + self.base_dn)
mod = "(A;CI;LC;;;AN)"
self.dacl_add_ace("OU=test_search_ou1," + self.base_dn, mod)
@@ -817,7 +801,7 @@ class AclSearchTests(AclTests):
self.assertEquals(len(res), 1)
self.assertTrue("dn" in res[0])
self.assertTrue(res[0]["dn"] == Dn(self.ldb_admin, self.configuration_dn))
- self.set_dsheuristics(self.dsheuristics)
+ self.ldb_admin.set_dsheuristics(self.dsheuristics)
def test_search1(self):
"""Make sure users can see us if given LC to user and group"""
@@ -1338,14 +1322,14 @@ class AclCARTests(AclTests):
self.minPwdAge = self.ldb_admin.get_minPwdAge()
# Set the "dSHeuristics" to have the tests run against Windows Server
- self.set_dsheuristics("000000001")
-# Set minPwdAge to 0
+ self.ldb_admin.set_dsheuristics("000000001")
+ # Set minPwdAge to 0
self.ldb_admin.set_minPwdAge("0")
def tearDown(self):
super(AclCARTests, self).tearDown()
#restore original values
- self.set_dsheuristics(self.dsheuristics)
+ self.ldb_admin.set_dsheuristics(self.dsheuristics)
self.ldb_admin.set_minPwdAge(self.minPwdAge)
self.delete_force(self.ldb_admin, self.get_user_dn(self.user_with_wp))
self.delete_force(self.ldb_admin, self.get_user_dn(self.user_with_pc))
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py
index e148e99..9caca7e 100755
--- a/source4/dsdb/tests/python/ldap.py
+++ b/source4/dsdb/tests/python/ldap.py
@@ -71,17 +71,6 @@ class BasicTests(unittest.TestCase):
res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE)
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
- def set_dsheuristics(self, dsheuristics):
- m = Message()
- m.dn = Dn(self.ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + self.configuration_dn)
- if dsheuristics is not None:
- m["dSHeuristics"] = MessageElement(dsheuristics, FLAG_MOD_REPLACE,
- "dSHeuristics")
- else:
- m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics")
- self.ldb.modify(m)
-
def setUp(self):
super(BasicTests, self).setUp()
self.ldb = ldb
@@ -2565,30 +2554,22 @@ nTSecurityDescriptor:: """ + desc_base64
print "Tests the 'dSHeuristics' attribute"""
# Get the current value to restore it later
- res = self.ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, "
- + self.configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"])
- if "dSHeuristics" in res[0]:
- dsheuristics = res[0]["dSHeuristics"][0]
- else:
- dsheuristics = None
+ dsheuristics = self.ldb.get_dsheuristics()
# Should not be longer than 18 chars?
try:
- self.set_dsheuristics("123ABC-+!1asdfg@#^12")
+ self.ldb.set_dsheuristics("123ABC-+!1asdfg@#^12")
except LdbError, (num, _):
self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)
# If it is >= 10 chars, tenthChar should be 1
try:
- self.set_dsheuristics("00020000000002")
+ self.ldb.set_dsheuristics("00020000000002")
except LdbError, (num, _):
self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)
# apart from the above, all char values are accepted
- self.set_dsheuristics("123ABC-+!1asdfg@#^")
- res = self.ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, "
- + self.configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"])
- self.assertTrue("dSHeuristics" in res[0])
- self.assertEquals(res[0]["dSHeuristics"][0], "123ABC-+!1asdfg@#^")
+ self.ldb.set_dsheuristics("123ABC-+!1asdfg@#^")
+ self.assertEquals(self.ldb.get_dsheuristics(), "123ABC-+!1asdfg@#^")
# restore old value
- self.set_dsheuristics(dsheuristics)
+ self.ldb.set_dsheuristics(dsheuristics)
class BaseDnTests(unittest.TestCase):
diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py
index 1512346..17eedb2 100755
--- a/source4/dsdb/tests/python/passwords.py
+++ b/source4/dsdb/tests/python/passwords.py
@@ -820,11 +820,7 @@ userPassword: thatsAcomplPASS4
print "Performs testing about the standard 'userPassword' behaviour"
# Delete the "dSHeuristics"
- m = Message()
- m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
- m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics")
- ldb.modify(m)
+ ldb.set_dsheuristics(None)
time.sleep(1) # This switching time is strictly needed!
@@ -864,12 +860,7 @@ userPassword: thatsAcomplPASS4
self.assertFalse("userPassword" in res[0])
# Set the test "dSHeuristics" to deactivate "userPassword" pwd changes
- m = Message()
- m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
- m["dSHeuristics"] = MessageElement("000000000", FLAG_MOD_REPLACE,
- "dSHeuristics")
- ldb.modify(m)
+ ldb.set_dsheuristics("000000000")
m = Message()
m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn)
@@ -884,12 +875,7 @@ userPassword: thatsAcomplPASS4
self.assertEquals(res[0]["userPassword"][0], "myPassword3")
# Set the test "dSHeuristics" to deactivate "userPassword" pwd changes
- m = Message()
- m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
- m["dSHeuristics"] = MessageElement("000000002", FLAG_MOD_REPLACE,
- "dSHeuristics")
- ldb.modify(m)
+ ldb.set_dsheuristics("000000002")
m = Message()
m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn)
@@ -904,12 +890,7 @@ userPassword: thatsAcomplPASS4
self.assertEquals(res[0]["userPassword"][0], "myPassword4")
# Reset the test "dSHeuristics" (reactivate "userPassword" pwd changes)
- m = Message()
- m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
- m["dSHeuristics"] = MessageElement("000000001", FLAG_MOD_REPLACE,
- "dSHeuristics")
- ldb.modify(m)
+ ldb.set_dsheuristics("000000001")
def tearDown(self):
super(PasswordTests, self).tearDown()
@@ -928,27 +909,19 @@ ldb = SamDB(url=host, session_info=system_session(), credentials=creds, lp=lp)
# Gets back the basedn
base_dn = ldb.domain_dn()
+
# Gets back the configuration basedn
configuration_dn = ldb.get_config_basedn().get_linearized()
# Get the old "dSHeuristics" if it was set
-res = ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"])
-if "dSHeuristics" in res[0]:
- dsheuristics = res[0]["dSHeuristics"][0]
-else:
- dsheuristics = None
+dsheuristics = ldb.get_dsheuristics()
# Set the "dSHeuristics" to activate the correct "userPassword" behaviour
-m = Message()
-m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
-m["dSHeuristics"] = MessageElement("000000001", FLAG_MOD_REPLACE,
- "dSHeuristics")
-ldb.modify(m)
+ldb.set_dsheuristics("000000001")
# Get the old "minPwdAge"
minPwdAge = ldb.get_minPwdAge()
+
# Set it temporarely to "0"
ldb.set_minPwdAge("0")
@@ -958,15 +931,7 @@ if not runner.run(unittest.makeSuite(PasswordTests)).wasSuccessful():
rc = 1
# Reset the "dSHeuristics" as they were before
-m = Message()
-m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
- + configuration_dn)
-if dsheuristics is not None:
- m["dSHeuristics"] = MessageElement(dsheuristics, FLAG_MOD_REPLACE,
- "dSHeuristics")
-else:
- m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics")
-ldb.modify(m)
+ldb.set_dsheuristics(dsheuristics)
# Reset the "minPwdAge" as it was before
ldb.set_minPwdAge(minPwdAge)
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 460c8b8..7bc461a 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -617,3 +617,27 @@ accountExpires: %u
return None
else:
return res[0]["minPwdAge"][0]
+
+ def set_dsheuristics(self, dsheuristics):
+ m = ldb.Message()
+ m.dn = ldb.Dn(self, "CN=Directory Service,CN=Windows NT,CN=Services,%s"
+ % self.get_config_basedn().get_linearized())
+ if dsheuristics is not None:
+ m["dSHeuristics"] = ldb.MessageElement(dsheuristics, ldb.FLAG_MOD_REPLACE,
+ "dSHeuristics")
+ else:
+ m["dSHeuristics"] = ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "dSHeuristics")
+ self.modify(m)
+
+ def get_dsheuristics(self):
+ res = self.search("CN=Directory Service,CN=Windows NT,CN=Services,%s"
+ % self.get_config_basedn().get_linearized(),
+ scope=ldb.SCOPE_BASE, attrs=["dSHeuristics"])
+ if len(res) == 0:
+ dsheuristics = None
+ elif "dSHeuristics" in res[0]:
+ dsheuristics = res[0]["dSHeuristics"][0]
+ else:
+ dsheuristics = None
+
+ return dsheuristics
--
Samba Shared Repository
More information about the samba-cvs
mailing list