def read_datafile(filename):
- paths = [ "../../../../../testdata/samba3",
- "../../../../testdata/samba3" ]
+ paths = ["../../../../../testdata/samba3",
+ "../../../../testdata/samba3"]
for p in paths:
datadir = os.path.join(os.path.dirname(__file__), p)
if os.path.exists(datadir):
break
return open(os.path.join(datadir, filename), 'r').read()
+
def ldb_debug(l, text):
print(text)
def __init__(self, basedn, dn, lp):
self.db = Ldb(lp=lp, session_info=system_session())
- self.db.set_opaque("skip_allocate_sids", "true");
+ self.db.set_opaque("skip_allocate_sids", "true")
self.basedn = basedn
self.basedn_casefold = ldb.Dn(self.db, basedn).get_casefold()
self.substvars = {"BASEDN": self.basedn}
def setUp(self):
super(Samba3SamTestCase, self).setUp()
ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session())
- ldb.set_opaque("skip_allocate_sids", "true");
+ ldb.set_opaque("skip_allocate_sids", "true")
self.samba3.setup_data("samba3.ldif")
ldif = read_datafile("provision_samba3sam.ldif")
ldb.add_ldif(self.samba4.subst(ldif))
self.setup_modules(ldb, self.samba3, self.samba4)
del ldb
self.ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session())
- self.ldb.set_opaque("skip_allocate_sids", "true");
+ self.ldb.set_opaque("skip_allocate_sids", "true")
def test_search_non_mapped(self):
"""Looking up by non-mapped attribute"""
#
msg = self.ldb.search(expression="(cn=Foo)", base="cn=Foo",
scope=SCOPE_BASE,
- attrs=['foo','blah','cn','showInAdvancedViewOnly'])
+ attrs=['foo', 'blah', 'cn', 'showInAdvancedViewOnly'])
self.assertEquals(len(msg), 1)
self.assertEquals(str(msg[0]["showInAdvancedViewOnly"]), "TRUE")
self.assertEquals(str(msg[0]["foo"]), "bar")
# Checking for existence of record (remote)
msg = self.ldb.search(expression="(unixName=bin)",
- attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
+ attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd'])
self.assertEquals(len(msg), 1)
self.assertEquals(str(msg[0]["cn"]), "Niemand")
self.assertEquals(str(msg[0]["sambaUnicodePwd"]), "geheim")
# Checking for existence of record (local && remote)
msg = self.ldb.search(expression="(&(unixName=bin)(sambaUnicodePwd=geheim))",
- attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
+ attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd'])
self.assertEquals(len(msg), 1) # TODO: should check with more records
self.assertEquals(str(msg[0]["cn"]), "Niemand")
self.assertEquals(str(msg[0]["unixName"]), "bin")
# Checking for existence of record (local || remote)
msg = self.ldb.search(expression="(|(unixName=bin)(sambaUnicodePwd=geheim))",
- attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
- #print "got %d replies" % len(msg)
+ attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd'])
+ # print "got %d replies" % len(msg)
self.assertEquals(len(msg), 1) # TODO: should check with more records
self.assertEquals(str(msg[0]["cn"]), "Niemand")
self.assertEquals(str(msg[0]["unixName"]), "bin")
def setUp(self):
super(MapTestCase, self).setUp()
ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session())
- ldb.set_opaque("skip_allocate_sids", "true");
+ ldb.set_opaque("skip_allocate_sids", "true")
ldif = read_datafile("provision_samba3sam.ldif")
ldb.add_ldif(self.samba4.subst(ldif))
self.setup_modules(ldb, self.samba3, self.samba4)
del ldb
self.ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session())
- self.ldb.set_opaque("skip_allocate_sids", "true");
+ self.ldb.set_opaque("skip_allocate_sids", "true")
def test_map_search(self):
"""Running search tests on mapped data."""
# Add a set of split records
self.ldb.add_ldif("""
-dn: """+ self.samba4.dn("cn=Domain Users") + """
+dn: """ + self.samba4.dn("cn=Domain Users") + """
objectClass: group
cn: Domain Users
objectSid: S-1-5-21-4231626423-2410014848-2360679739-513
# Add a set of split records
self.ldb.add_ldif("""
-dn: """+ self.samba4.dn("cn=X") + """
+dn: """ + self.samba4.dn("cn=X") + """
objectClass: user
cn: X
codePage: x
# TODO:
# Using the SID directly in the parse tree leads to conversion
# errors, letting the search fail with no results.
- #res = self.ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-1052)", scope=SCOPE_DEFAULT, attrs)
+ # res = self.ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-1052)", scope=SCOPE_DEFAULT, attrs)
res = self.ldb.search(expression="(objectSid=*)", base=None, scope=SCOPE_DEFAULT, attrs=["dnsHostName", "lastLogon", "objectSid"])
self.assertEquals(len(res), 4)
res = sorted(res, key=attrgetter('dn'))
# Note that Xs "objectSid" seems to be fine in the previous search for
# "objectSid"...
- #res = ldb.search(expression="(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs)
- #print len(res) + " results found"
- #for i in range(len(res)):
+ # res = ldb.search(expression="(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs)
+ # print len(res) + " results found"
+ # for i in range(len(res)):
# for (obj in res[i]) {
# print obj + ": " + res[i][obj]
# }
self.assertEquals(str(res[4]["lastLogon"]), "z")
# Clean up
- dns = [self.samba4.dn("cn=%s" % n) for n in ["A","B","C","X","Y","Z"]]
+ dns = [self.samba4.dn("cn=%s" % n) for n in ["A", "B", "C", "X", "Y", "Z"]]
for dn in dns:
self.ldb.delete(dn)