1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

scripting: Fill the ProvisionNames hash with strings, not ldb.MessageElement or Dn

This avoids the need to fix it up again in samba_upgradedns.

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Mar 25 13:25:30 CET 2013 on sn-devel-104
This commit is contained in:
Andrew Bartlett 2013-03-22 21:58:25 +11:00 committed by Stefan Metzmacher
parent 5d42260eec
commit 30adf0cdba
2 changed files with 8 additions and 23 deletions

View File

@ -201,9 +201,8 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
"configurationNamingContext","rootDomainNamingContext", "configurationNamingContext","rootDomainNamingContext",
"namingContexts"]) "namingContexts"])
names.configdn = current[0]["configurationNamingContext"] names.configdn = current[0]["configurationNamingContext"][0]
configdn = str(names.configdn) names.schemadn = current[0]["schemaNamingContext"][0]
names.schemadn = current[0]["schemaNamingContext"]
if not (ldb.Dn(samdb, basedn) == (ldb.Dn(samdb, if not (ldb.Dn(samdb, basedn) == (ldb.Dn(samdb,
current[0]["defaultNamingContext"][0]))): current[0]["defaultNamingContext"][0]))):
raise ProvisioningError(("basedn in %s (%s) and from %s (%s)" raise ProvisioningError(("basedn in %s (%s) and from %s (%s)"
@ -211,8 +210,8 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
str(current[0]["defaultNamingContext"][0]), str(current[0]["defaultNamingContext"][0]),
paths.smbconf, basedn))) paths.smbconf, basedn)))
names.domaindn=current[0]["defaultNamingContext"] names.domaindn=current[0]["defaultNamingContext"][0]
names.rootdn=current[0]["rootDomainNamingContext"] names.rootdn=current[0]["rootDomainNamingContext"][0]
names.ncs=current[0]["namingContexts"] names.ncs=current[0]["namingContexts"]
names.dnsforestdn = None names.dnsforestdn = None
names.dnsdomaindn = None names.dnsdomaindn = None
@ -232,7 +231,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
# default site name # default site name
res3 = samdb.search(expression="(objectClass=site)", res3 = samdb.search(expression="(objectClass=site)",
base="CN=Sites," + configdn, scope=ldb.SCOPE_ONELEVEL, attrs=["cn"]) base="CN=Sites," + names.configdn, scope=ldb.SCOPE_ONELEVEL, attrs=["cn"])
names.sitename = str(res3[0]["cn"]) names.sitename = str(res3[0]["cn"])
# dns hostname and server dn # dns hostname and server dn
@ -242,8 +241,8 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
names.hostname = str(res4[0]["dNSHostName"]).replace("." + names.dnsdomain, "") names.hostname = str(res4[0]["dNSHostName"]).replace("." + names.dnsdomain, "")
server_res = samdb.search(expression="serverReference=%s" % res4[0].dn, server_res = samdb.search(expression="serverReference=%s" % res4[0].dn,
attrs=[], base=configdn) attrs=[], base=names.configdn)
names.serverdn = server_res[0].dn names.serverdn = str(server_res[0].dn)
# invocation id/objectguid # invocation id/objectguid
res5 = samdb.search(expression="(objectClass=*)", res5 = samdb.search(expression="(objectClass=*)",

View File

@ -83,19 +83,6 @@ def find_bind_gid():
return None return None
def fix_names(pnames):
"""Convert elements to strings from MessageElement
"""
names = pnames
names.rootdn = pnames.rootdn[0]
names.domaindn = pnames.domaindn[0]
names.configdn = pnames.configdn[0]
names.schemadn = pnames.schemadn[0]
names.root_gid = pnames.root_gid
names.serverdn = str(pnames.serverdn)
return names
def convert_dns_rdata(rdata, serial=1): def convert_dns_rdata(rdata, serial=1):
"""Convert resource records in dnsRecord format """Convert resource records in dnsRecord format
""" """
@ -270,9 +257,8 @@ if __name__ == '__main__':
paths = get_paths(param, smbconf=lp.configfile) paths = get_paths(param, smbconf=lp.configfile)
paths.bind_gid = find_bind_gid() paths.bind_gid = find_bind_gid()
ldbs = get_ldbs(paths, creds, system_session(), lp) ldbs = get_ldbs(paths, creds, system_session(), lp)
pnames = find_provision_key_parameters(ldbs.sam, ldbs.secrets, ldbs.idmap, names = find_provision_key_parameters(ldbs.sam, ldbs.secrets, ldbs.idmap,
paths, lp.configfile, lp) paths, lp.configfile, lp)
names = fix_names(pnames)
if names.domainlevel < DS_DOMAIN_FUNCTION_2003: if names.domainlevel < DS_DOMAIN_FUNCTION_2003:
logger.error("Cannot create AD based DNS for OS level < 2003") logger.error("Cannot create AD based DNS for OS level < 2003")