diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-09-16 15:15:35 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-09-19 10:57:03 +1000 |
commit | 966b5d5de2fc40ff77e2b947c61a2419795a2282 (patch) | |
tree | 493acc3376969e639b126b82bd50c69daf2eb009 /source4 | |
parent | f79d6ee929884ad76f2a88fc67c660fec31b8ed7 (diff) | |
download | samba-966b5d5de2fc40ff77e2b947c61a2419795a2282.tar.gz samba-966b5d5de2fc40ff77e2b947c61a2419795a2282.tar.bz2 samba-966b5d5de2fc40ff77e2b947c61a2419795a2282.zip |
pyldb: fixed places where we try to concatenate a Dn with a string
you need to either use str(dn) or use %s in a format string
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/dsdb/tests/python/ldap.py | 30 | ||||
-rwxr-xr-x | source4/dsdb/tests/python/urgent_replication.py | 2 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/domain.py | 10 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/fsmo.py | 2 |
4 files changed, 22 insertions, 22 deletions
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index fa2c16e944..9f5b82f5cb 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -1574,7 +1574,7 @@ objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d self.assertEquals(res[0]["objectClass"][4], "computer"); self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) - self.assertEquals(res[0]["objectCategory"][0], ("CN=Computer," + ldb.get_schema_basedn())) + self.assertEquals(res[0]["objectCategory"][0], ("CN=Computer,%s" % ldb.get_schema_basedn())) self.assertEquals(int(res[0]["primaryGroupID"][0]), 513); self.assertEquals(int(res[0]["sAMAccountType"][0]), ATYPE_NORMAL_ACCOUNT); self.assertEquals(int(res[0]["userAccountControl"][0]), UF_NORMAL_ACCOUNT | UF_PASSWD_NOTREQD | UF_ACCOUNTDISABLE); @@ -1883,7 +1883,7 @@ servicePrincipalName: host/ldaptest2computer29 except LdbError, (num, _): self.assertEquals(num, ERR_ENTRY_ALREADY_EXISTS) try: - ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser3," + ldb.get_config_basedn()) + ldb.rename("cn=ldaptestuser3,cn=users,%s" % self.base_dn, "cn=ldaptestuser3,%s" % ldb.get_config_basedn()) self.fail() except LdbError, (num, _): self.assertTrue(num in (71, 64)) @@ -2014,15 +2014,15 @@ member: cn=ldaptestuser2,cn=users,""" + self.base_dn + """ self.assertEquals(set(res[0]["objectClass"]), set(["top", "person", "organizationalPerson", "user"])) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) - self.assertEquals(str(res[0]["objectCategory"]), ("CN=Person," + ldb.get_schema_basedn())) + self.assertEquals(str(res[0]["objectCategory"]), ("CN=Person,%s" % ldb.get_schema_basedn())) self.assertEquals(int(res[0]["sAMAccountType"][0]), ATYPE_NORMAL_ACCOUNT) self.assertEquals(int(res[0]["userAccountControl"][0]), UF_NORMAL_ACCOUNT | UF_PASSWD_NOTREQD | UF_ACCOUNTDISABLE) self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper()) self.assertEquals(len(res[0]["memberOf"]), 1) - print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=cn=person," + ldb.get_schema_basedn() + "))" - res2 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=cn=person," + ldb.get_schema_basedn() + "))") - self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestuser)(objectCategory=cn=person," + ldb.get_schema_basedn() + "))") + print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=cn=person,%s))" % ldb.get_schema_basedn() + res2 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=cn=person,%s))" % ldb.get_schema_basedn()) + self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestuser)(objectCategory=cn=person,%s))" % ldb.get_schema_basedn()) self.assertEquals(res[0].dn, res2[0].dn) @@ -2059,23 +2059,23 @@ member: cn=ldaptestuser2,cn=users,""" + self.base_dn + """ self.assertEquals(set(res[0]["objectClass"]), set(["top", "person", "organizationalPerson", "user", "computer"])) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) - self.assertEquals(str(res[0]["objectCategory"]), ("CN=Computer," + ldb.get_schema_basedn())) + self.assertEquals(str(res[0]["objectCategory"]), ("CN=Computer,%s" % ldb.get_schema_basedn())) self.assertEquals(int(res[0]["primaryGroupID"][0]), 513) self.assertEquals(int(res[0]["sAMAccountType"][0]), ATYPE_NORMAL_ACCOUNT) self.assertEquals(int(res[0]["userAccountControl"][0]), UF_NORMAL_ACCOUNT | UF_PASSWD_NOTREQD | UF_ACCOUNTDISABLE) self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper()) self.assertEquals(len(res[0]["memberOf"]), 1) - print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer," + ldb.get_schema_basedn() + "))" - res2 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer," + ldb.get_schema_basedn() + "))") - self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer," + ldb.get_schema_basedn() + "))") + print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s))" % ldb.get_schema_basedn() + res2 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s))" % ldb.get_schema_basedn()) + self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s))" % ldb.get_schema_basedn()) self.assertEquals(res[0].dn, res2[0].dn) if gc_ldb is not None: - print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer," + gc_ldb.get_schema_basedn() + ")) in Global Catlog" - res2gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer," + gc_ldb.get_schema_basedn() + "))") - self.assertEquals(len(res2gc), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer," + gc_ldb.get_schema_basedn() + ")) in Global Catlog") + print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s)) in Global Catalog" % gc_ldb.get_schema_basedn() + res2gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s))" % gc_ldb.get_schema_basedn()) + self.assertEquals(len(res2gc), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,%s)) In Global Catalog" % gc_ldb.get_schema_basedn()) self.assertEquals(res[0].dn, res2gc[0].dn) @@ -2122,7 +2122,7 @@ member: cn=ldaptestuser2,cn=users,""" + self.base_dn + """ self.assertEquals(list(res[0]["objectClass"]), ["top", "person", "organizationalPerson", "user", "computer"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) - self.assertEquals(res[0]["objectCategory"][0], "CN=Computer," + ldb.get_schema_basedn()) + self.assertEquals(res[0]["objectCategory"][0], "CN=Computer,%s" % ldb.get_schema_basedn()) self.assertEquals(int(res[0]["sAMAccountType"][0]), ATYPE_WORKSTATION_TRUST) self.assertEquals(int(res[0]["userAccountControl"][0]), UF_WORKSTATION_TRUST_ACCOUNT) @@ -2761,7 +2761,7 @@ class BaseDnTests(unittest.TestCase): self.assertEquals(len(res4[0]["msDS-Behavior-Version"]), 1) self.assertEquals(int(res[0]["domainFunctionality"][0]), int(res4[0]["msDS-Behavior-Version"][0])) - res5 = self.ldb.search("cn=partitions," + str(ldb.get_config_basedn()), scope=SCOPE_BASE, attrs=["msDS-Behavior-Version"]) + res5 = self.ldb.search("cn=partitions,%s" % ldb.get_config_basedn(), scope=SCOPE_BASE, attrs=["msDS-Behavior-Version"]) self.assertEquals(len(res5), 1) self.assertEquals(len(res5[0]["msDS-Behavior-Version"]), 1) self.assertEquals(int(res[0]["forestFunctionality"][0]), int(res5[0]["msDS-Behavior-Version"][0])) diff --git a/source4/dsdb/tests/python/urgent_replication.py b/source4/dsdb/tests/python/urgent_replication.py index 40921e1cb1..2a07a58d86 100755 --- a/source4/dsdb/tests/python/urgent_replication.py +++ b/source4/dsdb/tests/python/urgent_replication.py @@ -87,7 +87,7 @@ class UrgentReplicationTests(samba.tests.TestCase): '''Test if the urgent replication is activated when handling a nTDSDSA object''' self.ldb.add({ - "dn": "cn=test server,cn=Servers,cn=Default-First-Site-Name,cn=Sites," + self.ldb.get_config_basedn(), + "dn": "cn=test server,cn=Servers,cn=Default-First-Site-Name,cn=Sites,%s" % self.ldb.get_config_basedn(), "objectclass":"server", "cn":"test server", "name":"test server", diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py index f7e060f730..0ab35a63aa 100644 --- a/source4/scripting/python/samba/netcmd/domain.py +++ b/source4/scripting/python/samba/netcmd/domain.py @@ -164,7 +164,7 @@ class cmd_domain_level(Command): domain_dn = samdb.domain_dn() - res_forest = samdb.search("CN=Partitions," + samdb.get_config_basedn(), + res_forest = samdb.search("CN=Partitions,%s" % samdb.get_config_basedn(), scope=ldb.SCOPE_BASE, attrs=["msDS-Behavior-Version"]) assert len(res_forest) == 1 @@ -172,7 +172,7 @@ class cmd_domain_level(Command): attrs=["msDS-Behavior-Version", "nTMixedDomain"]) assert len(res_domain) == 1 - res_dc_s = samdb.search("CN=Sites," + samdb.get_config_basedn(), + res_dc_s = samdb.search("CN=Sites,%s" % samdb.get_config_basedn(), scope=ldb.SCOPE_SUBTREE, expression="(objectClass=nTDSDSA)", attrs=["msDS-Behavior-Version"]) assert len(res_dc_s) >= 1 @@ -279,7 +279,7 @@ class cmd_domain_level(Command): samdb.modify(m) # Under partitions m = ldb.Message() - m.dn = ldb.Dn(samdb, "CN=" + lp.get("workgroup") + ",CN=Partitions," + ldb.get_config_basedn()) + m.dn = ldb.Dn(samdb, "CN=" + lp.get("workgroup") + ",CN=Partitions,%s" % ldb.get_config_basedn()) m["nTMixedDomain"] = ldb.MessageElement("0", ldb.FLAG_MOD_REPLACE, "nTMixedDomain") try: @@ -298,7 +298,7 @@ class cmd_domain_level(Command): # Under partitions m = ldb.Message() m.dn = ldb.Dn(samdb, "CN=" + lp.get("workgroup") - + ",CN=Partitions," + ldb.get_config_basedn()) + + ",CN=Partitions,%s" % ldb.get_config_basedn()) m["msDS-Behavior-Version"]= ldb.MessageElement( str(new_level_domain), ldb.FLAG_MOD_REPLACE, "msDS-Behavior-Version") @@ -323,7 +323,7 @@ class cmd_domain_level(Command): if new_level_forest > level_domain: raise CommandError("Forest function level can't be higher than the domain function level(s). Please raise it/them first!") m = ldb.Message() - m.dn = ldb.Dn(samdb, "CN=Partitions," + ldb.get_config_basedn()) + m.dn = ldb.Dn(samdb, "CN=Partitions,%s" % ldb.get_config_basedn()) m["msDS-Behavior-Version"]= ldb.MessageElement( str(new_level_forest), ldb.FLAG_MOD_REPLACE, "msDS-Behavior-Version") diff --git a/source4/scripting/python/samba/netcmd/fsmo.py b/source4/scripting/python/samba/netcmd/fsmo.py index 78a2014825..06a2de1c2c 100644 --- a/source4/scripting/python/samba/netcmd/fsmo.py +++ b/source4/scripting/python/samba/netcmd/fsmo.py @@ -139,7 +139,7 @@ class cmd_fsmo_show(Command): domain_dn = samdb.domain_dn() self.infrastructure_dn = "CN=Infrastructure," + domain_dn - self.naming_dn = "CN=Partitions," + samdb.get_config_basedn() + self.naming_dn = "CN=Partitions,%s" % samdb.get_config_basedn() self.schema_dn = samdb.get_schema_basedn() self.rid_dn = "CN=RID Manager$,CN=System," + domain_dn |