From 5b3c71cd9c4d20a04f7505ad904f95d0ecf5ac2e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 Mar 2015 13:22:37 +1300 Subject: [PATCH] provision: Give a more helpful message when find_provision_key_parameters() fails Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Fri Mar 6 20:11:52 CET 2015 on sn-devel-104 --- python/samba/provision/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index 1603321bd8b..953bd0f3bd3 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -243,8 +243,11 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # dns hostname and server dn res4 = samdb.search(expression="(CN=%s)" % names.netbiosname, - base="OU=Domain Controllers,%s" % basedn, - scope=ldb.SCOPE_ONELEVEL, attrs=["dNSHostName"]) + base="OU=Domain Controllers,%s" % basedn, + scope=ldb.SCOPE_ONELEVEL, attrs=["dNSHostName"]) + if len(res4) == 0: + raise ProvisioningError("Unable to find DC called CN=%s under OU=Domain Controllers,%s" % (names.netbiosname, basedn)) + names.hostname = str(res4[0]["dNSHostName"]).replace("." + names.dnsdomain, "") server_res = samdb.search(expression="serverReference=%s" % res4[0].dn,