summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource4/dsdb/tests/python/deletetest.py12
-rwxr-xr-xsource4/dsdb/tests/python/ldap.py11
-rwxr-xr-xsource4/dsdb/tests/python/ldap_schema.py12
-rw-r--r--source4/dsdb/tests/python/ldap_syntaxes.py8
-rwxr-xr-xsource4/dsdb/tests/python/passwords.py8
-rwxr-xr-xsource4/dsdb/tests/python/sam.py18
-rwxr-xr-xsource4/dsdb/tests/python/urgent_replication.py8
7 files changed, 15 insertions, 62 deletions
diff --git a/source4/dsdb/tests/python/deletetest.py b/source4/dsdb/tests/python/deletetest.py
index 8ed5281a4c..7582d4bef7 100755
--- a/source4/dsdb/tests/python/deletetest.py
+++ b/source4/dsdb/tests/python/deletetest.py
@@ -16,7 +16,7 @@ from samba.auth import system_session
from ldb import SCOPE_BASE, LdbError
from ldb import ERR_NO_SUCH_OBJECT, ERR_NOT_ALLOWED_ON_NON_LEAF
from ldb import ERR_UNWILLING_TO_PERFORM
-from samba import Ldb
+from samba.samdb import SamDB
from subunit.run import SubunitTestRunner
import unittest
@@ -50,12 +50,6 @@ class BasicDeleteTests(unittest.TestCase):
def GUID_string(self, guid):
return self.ldb.schema_format_value("objectGUID", guid)
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def find_configurationdn(self, ldb):
res = ldb.search(base="", expression="", scope=SCOPE_BASE,
attrs=["configurationNamingContext"])
@@ -64,7 +58,7 @@ class BasicDeleteTests(unittest.TestCase):
def setUp(self):
self.ldb = ldb
- self.base_dn = self.find_basedn(ldb)
+ self.base_dn = ldb.domain_dn()
self.configuration_dn = self.find_configurationdn(ldb)
def search_guid(self, guid):
@@ -395,7 +389,7 @@ if not "://" in host:
else:
host = "ldap://%s" % host
-ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp)
+ldb = SamDB(host, credentials=creds, session_info=system_session(), lp=lp)
runner = SubunitTestRunner()
rc = 0
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py
index 00cc450109..fb191c623a 100755
--- a/source4/dsdb/tests/python/ldap.py
+++ b/source4/dsdb/tests/python/ldap.py
@@ -27,6 +27,7 @@ from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
from ldb import timestring
from samba import Ldb
+from samba.samdb import SamDB
from samba.dsdb import (UF_NORMAL_ACCOUNT,
UF_WORKSTATION_TRUST_ACCOUNT,
UF_PASSWD_NOTREQD, UF_ACCOUNTDISABLE, ATYPE_NORMAL_ACCOUNT,
@@ -66,12 +67,6 @@ class BasicTests(unittest.TestCase):
except LdbError, (num, _):
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def find_configurationdn(self, ldb):
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
self.assertEquals(len(res), 1)
@@ -101,7 +96,7 @@ class BasicTests(unittest.TestCase):
super(BasicTests, self).setUp()
self.ldb = ldb
self.gc_ldb = gc_ldb
- self.base_dn = self.find_basedn(ldb)
+ self.base_dn = ldb.domain_dn()
self.configuration_dn = self.find_configurationdn(ldb)
self.schema_dn = self.find_schemadn(ldb)
self.domain_sid = self.find_domain_sid()
@@ -2638,7 +2633,7 @@ if not "://" in host:
else:
host = "ldap://%s" % host
-ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp)
+ldb = SamDB(host, credentials=creds, session_info=system_session(), lp=lp)
if not "tdb://" in host:
gc_ldb = Ldb("%s:3268" % host, credentials=creds,
session_info=system_session(), lp=lp)
diff --git a/source4/dsdb/tests/python/ldap_schema.py b/source4/dsdb/tests/python/ldap_schema.py
index a296b8daaf..168cea39d3 100755
--- a/source4/dsdb/tests/python/ldap_schema.py
+++ b/source4/dsdb/tests/python/ldap_schema.py
@@ -22,7 +22,7 @@ from ldb import ERR_UNWILLING_TO_PERFORM
from ldb import ERR_CONSTRAINT_VIOLATION
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_REPLACE
-from samba import Ldb
+from samba.samdb import SamDB
from samba.dsdb import DS_DOMAIN_FUNCTION_2003
from subunit.run import SubunitTestRunner
@@ -60,17 +60,11 @@ class SchemaTests(unittest.TestCase):
self.assertEquals(len(res), 1)
return res[0]["schemaNamingContext"][0]
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def setUp(self):
super(SchemaTests, self).setUp()
self.ldb = ldb
+ self.base_dn = ldb.domain_dn()
self.schema_dn = self.find_schemadn(ldb)
- self.base_dn = self.find_basedn(ldb)
def test_generated_schema(self):
"""Testing we can read the generated schema via LDAP"""
@@ -583,7 +577,7 @@ if host.startswith("ldap://"):
# user 'paged_search' module when connecting remotely
ldb_options = ["modules:paged_searches"]
-ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp, options=ldb_options)
+ldb = SamDB(host, credentials=creds, session_info=system_session(), lp=lp, options=ldb_options)
runner = SubunitTestRunner()
rc = 0
diff --git a/source4/dsdb/tests/python/ldap_syntaxes.py b/source4/dsdb/tests/python/ldap_syntaxes.py
index f5d2dcba16..c1dd4d546e 100644
--- a/source4/dsdb/tests/python/ldap_syntaxes.py
+++ b/source4/dsdb/tests/python/ldap_syntaxes.py
@@ -61,12 +61,6 @@ class SyntaxTests(unittest.TestCase):
self.assertEquals(len(res), 1)
return res[0]["schemaNamingContext"][0]
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def _find_domain_sid(self):
res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE)
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
@@ -74,8 +68,8 @@ class SyntaxTests(unittest.TestCase):
def setUp(self):
super(SyntaxTests, self).setUp()
self.ldb = ldb
+ self.base_dn = ldb.domain_dn()
self.schema_dn = self.find_schemadn(ldb)
- self.base_dn = self.find_basedn(ldb)
self._setup_dn_string_test()
self._setup_dn_binary_test()
self.domain_sid = self._find_domain_sid()
diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py
index 8cb7136ebb..f238c1adc4 100755
--- a/source4/dsdb/tests/python/passwords.py
+++ b/source4/dsdb/tests/python/passwords.py
@@ -69,16 +69,10 @@ class PasswordTests(samba.tests.TestCase):
except LdbError, (num, _):
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def setUp(self):
super(PasswordTests, self).setUp()
self.ldb = ldb
- self.base_dn = self.find_basedn(ldb)
+ self.base_dn = ldb.domain_dn()
# (Re)adds the test user "testuser" with no password atm
self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn)
diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py
index c3490dae67..f8871b7e52 100755
--- a/source4/dsdb/tests/python/sam.py
+++ b/source4/dsdb/tests/python/sam.py
@@ -23,7 +23,7 @@ from ldb import ERR_CONSTRAINT_VIOLATION
from ldb import ERR_UNDEFINED_ATTRIBUTE_TYPE
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
-from samba import Ldb
+from samba.samdb import SamDB
from samba.dsdb import (UF_NORMAL_ACCOUNT,
UF_WORKSTATION_TRUST_ACCOUNT, UF_SERVER_TRUST_ACCOUNT,
UF_PARTIAL_SECRETS_ACCOUNT, UF_TEMP_DUPLICATE_ACCOUNT,
@@ -71,12 +71,6 @@ class SamTests(unittest.TestCase):
except LdbError, (num, _):
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def find_domain_sid(self):
res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE)
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
@@ -84,8 +78,7 @@ class SamTests(unittest.TestCase):
def setUp(self):
super(SamTests, self).setUp()
self.ldb = ldb
- self.gc_ldb = gc_ldb
- self.base_dn = self.find_basedn(ldb)
+ self.base_dn = ldb.domain_dn()
self.domain_sid = self.find_domain_sid()
print "baseDN: %s\n" % self.base_dn
@@ -2419,12 +2412,7 @@ if not "://" in host:
else:
host = "ldap://%s" % host
-ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp)
-if not "tdb://" in host:
- gc_ldb = Ldb("%s:3268" % host, credentials=creds,
- session_info=system_session(), lp=lp)
-else:
- gc_ldb = None
+ldb = SamDB(host, credentials=creds, session_info=system_session(), lp=lp)
runner = SubunitTestRunner()
rc = 0
diff --git a/source4/dsdb/tests/python/urgent_replication.py b/source4/dsdb/tests/python/urgent_replication.py
index 2ab8c5422e..88cef4dfad 100755
--- a/source4/dsdb/tests/python/urgent_replication.py
+++ b/source4/dsdb/tests/python/urgent_replication.py
@@ -48,16 +48,10 @@ class UrgentReplicationTests(samba.tests.TestCase):
except LdbError, (num, _):
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
- def find_basedn(self, ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- self.assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
def setUp(self):
super(UrgentReplicationTests, self).setUp()
self.ldb = ldb
- self.base_dn = self.find_basedn(ldb)
+ self.base_dn = ldb.domain_dn()
print "baseDN: %s\n" % self.base_dn