summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Babinsky <mbabinsk@redhat.com>2017-02-16 13:41:32 +0100
committerMartin Basti <mbasti@redhat.com>2017-03-01 15:55:45 +0100
commitc5bae577597fbababdd25ab3ae6463c490d90a40 (patch)
tree7f5e31bc1b8f2c9dd18c4f300ef2e5fbeb4563d6
parent4ba6b968399204aac66d82d917a8cc159e77ad4d (diff)
downloadfreeipa-c5bae577597fbababdd25ab3ae6463c490d90a40.tar.gz
freeipa-c5bae577597fbababdd25ab3ae6463c490d90a40.tar.xz
freeipa-c5bae577597fbababdd25ab3ae6463c490d90a40.zip
only check for netbios name when LDAP backend is connected
This is to prevent errors due to non-existent LDAP connection such as when installing first IPA master. https://fedorahosted.org/freeipa/ticket/6630 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
-rw-r--r--ipaserver/install/adtrust.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/ipaserver/install/adtrust.py b/ipaserver/install/adtrust.py
index 69e9834f7..fd26e6962 100644
--- a/ipaserver/install/adtrust.py
+++ b/ipaserver/install/adtrust.py
@@ -59,6 +59,21 @@ def read_netbios_name(netbios_default):
return netbios_name
+def retrieve_netbios_name(api):
+ flat_name_attr = 'ipantflatname'
+ try:
+ entry = api.Backend.ldap2.get_entry(
+ DN(('cn', api.env.domain), api.env.container_cifsdomains,
+ ipautil.realm_to_suffix(api.env.realm)),
+ [flat_name_attr])
+ except errors.NotFound:
+ # trust not configured
+ root_logger.debug("No previous trust configuration found")
+ return None
+ else:
+ return entry.get(flat_name_attr)[0]
+
+
def set_and_check_netbios_name(netbios_name, unattended, api):
"""
Depending if trust in already configured or not a given NetBIOS domain
@@ -71,22 +86,16 @@ def set_and_check_netbios_name(netbios_name, unattended, api):
the stored NetBIOS name it it differs from the current one.
"""
- flat_name_attr = 'ipantflatname'
cur_netbios_name = None
gen_netbios_name = None
reset_netbios_name = False
entry = None
- try:
- entry = api.Backend.ldap2.get_entry(
- DN(('cn', api.env.domain), api.env.container_cifsdomains,
- ipautil.realm_to_suffix(api.env.realm)),
- [flat_name_attr])
- except errors.NotFound:
- # trust not configured
- pass
+ if api.Backend.ldap2.isconnected():
+ cur_netbios_name = retrieve_netbios_name(api)
else:
- cur_netbios_name = entry.get(flat_name_attr)[0]
+ root_logger.debug(
+ "LDAP is not connected, can not retrieve NetBIOS name")
if cur_netbios_name and not netbios_name:
# keep the current NetBIOS name