|
@@ -43,7 +43,6 @@ if sys.version_info[0] > 2:
|
|
|
else:
|
|
else:
|
|
|
from django.utils.translation import ugettext as _
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
|
|
-
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
LOG = logging.getLogger(__name__)
|
|
|
LOG.setLevel(logging.DEBUG)
|
|
LOG.setLevel(logging.DEBUG)
|
|
|
ch = logging.StreamHandler(sys.stdout)
|
|
ch = logging.StreamHandler(sys.stdout)
|
|
@@ -142,6 +141,7 @@ will typically work with Active Directory/LDAP. Typically this is member
|
|
|
for Active Directory and LDAP.
|
|
for Active Directory and LDAP.
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class Command(BaseCommand):
|
|
class Command(BaseCommand):
|
|
|
def print_ldap_global_settings(self, cfg, is_multi_ldap):
|
|
def print_ldap_global_settings(self, cfg, is_multi_ldap):
|
|
|
LOG.info('[desktop]')
|
|
LOG.info('[desktop]')
|
|
@@ -205,7 +205,7 @@ class Command(BaseCommand):
|
|
|
return err_code
|
|
return err_code
|
|
|
|
|
|
|
|
if not ((ldap_url.startswith("ldap") and
|
|
if not ((ldap_url.startswith("ldap") and
|
|
|
- "://" in ldap_url)):
|
|
|
|
|
|
|
+ "://" in ldap_url)):
|
|
|
LOG.info(_(ldap_url_msg))
|
|
LOG.info(_(ldap_url_msg))
|
|
|
LOG.warning("Check your ldap_url=%s" % ldap_url)
|
|
LOG.warning("Check your ldap_url=%s" % ldap_url)
|
|
|
return err_code
|
|
return err_code
|
|
@@ -231,12 +231,12 @@ class Command(BaseCommand):
|
|
|
user_name_attr = ldap_config.USERS.USER_NAME_ATTR.get()
|
|
user_name_attr = ldap_config.USERS.USER_NAME_ATTR.get()
|
|
|
user_filter = ldap_config.USERS.USER_FILTER.get()
|
|
user_filter = ldap_config.USERS.USER_FILTER.get()
|
|
|
bind_password = ldap_config.BIND_PASSWORD.get()
|
|
bind_password = ldap_config.BIND_PASSWORD.get()
|
|
|
- if user_name_attr=='' or ' ' in user_name_attr:
|
|
|
|
|
|
|
+ if user_name_attr == '' or ' ' in user_name_attr:
|
|
|
LOG.info(_(user_name_attr_msg))
|
|
LOG.info(_(user_name_attr_msg))
|
|
|
LOG.warning("Could not find user_name_attr in hue.ini")
|
|
LOG.warning("Could not find user_name_attr in hue.ini")
|
|
|
return err_code
|
|
return err_code
|
|
|
|
|
|
|
|
- if user_filter=='':
|
|
|
|
|
|
|
+ if user_filter == '':
|
|
|
LOG.info(_(user_filter_msg))
|
|
LOG.info(_(user_filter_msg))
|
|
|
LOG.warning("Could not find user_filter in hue.ini required for authentication")
|
|
LOG.warning("Could not find user_filter in hue.ini required for authentication")
|
|
|
return err_code
|
|
return err_code
|
|
@@ -303,7 +303,7 @@ class Command(BaseCommand):
|
|
|
if users:
|
|
if users:
|
|
|
for user in users:
|
|
for user in users:
|
|
|
LOG.info('%s' % user)
|
|
LOG.info('%s' % user)
|
|
|
- if user.get('username', '')=='':
|
|
|
|
|
|
|
+ if user.get('username', '') == '':
|
|
|
LOG.info(_(user_name_attr_msg))
|
|
LOG.info(_(user_name_attr_msg))
|
|
|
LOG.warning('hints: check user_name_attr="%s"' % ldap_config.USERS.USER_NAME_ATTR.get())
|
|
LOG.warning('hints: check user_name_attr="%s"' % ldap_config.USERS.USER_NAME_ATTR.get())
|
|
|
err_code = 1
|
|
err_code = 1
|
|
@@ -344,7 +344,7 @@ class Command(BaseCommand):
|
|
|
LOG.warning(ldap_obj.ldapsearch_cmd())
|
|
LOG.warning(ldap_obj.ldapsearch_cmd())
|
|
|
return err_code
|
|
return err_code
|
|
|
else:
|
|
else:
|
|
|
- LOG.info(ldap_obj.ldapsearch_cmd())
|
|
|
|
|
|
|
+ LOG.info(ldap_obj.ldapsearch_cmd())
|
|
|
|
|
|
|
|
if groups:
|
|
if groups:
|
|
|
for grp in groups:
|
|
for grp in groups:
|
|
@@ -387,7 +387,7 @@ class Command(BaseCommand):
|
|
|
if groups:
|
|
if groups:
|
|
|
for grp in groups:
|
|
for grp in groups:
|
|
|
LOG.info('%s' % grp)
|
|
LOG.info('%s' % grp)
|
|
|
- if grp.get('members', [])==[]:
|
|
|
|
|
|
|
+ if grp.get('members', []) == []:
|
|
|
LOG.info(_(group_member_attr_msg))
|
|
LOG.info(_(group_member_attr_msg))
|
|
|
LOG.warning('hints: check group_member_attr="%s"' % ldap_config.GROUPS.GROUP_MEMBER_ATTR.get())
|
|
LOG.warning('hints: check group_member_attr="%s"' % ldap_config.GROUPS.GROUP_MEMBER_ATTR.get())
|
|
|
err_code = 1
|
|
err_code = 1
|
|
@@ -429,7 +429,7 @@ class Command(BaseCommand):
|
|
|
if groups:
|
|
if groups:
|
|
|
for grp in groups:
|
|
for grp in groups:
|
|
|
LOG.info('%s' % grp)
|
|
LOG.info('%s' % grp)
|
|
|
- if grp.get('members',[])==[]:
|
|
|
|
|
|
|
+ if grp.get('members', []) == []:
|
|
|
LOG.info(_(group_member_attr_msg))
|
|
LOG.info(_(group_member_attr_msg))
|
|
|
LOG.warning('hints: check group_member_attr="%s"' % ldap_config.GROUPS.GROUP_MEMBER_ATTR.get())
|
|
LOG.warning('hints: check group_member_attr="%s"' % ldap_config.GROUPS.GROUP_MEMBER_ATTR.get())
|
|
|
err_code = 1
|
|
err_code = 1
|
|
@@ -439,7 +439,7 @@ class Command(BaseCommand):
|
|
|
return err_code
|
|
return err_code
|
|
|
|
|
|
|
|
def sys_exit(self, exit_code):
|
|
def sys_exit(self, exit_code):
|
|
|
- if exit_code!=0:
|
|
|
|
|
|
|
+ if exit_code != 0:
|
|
|
LOG.warning('LDAP Test Command failed')
|
|
LOG.warning('LDAP Test Command failed')
|
|
|
sys.exit(exit_code)
|
|
sys.exit(exit_code)
|
|
|
|
|
|
|
@@ -471,7 +471,6 @@ class Command(BaseCommand):
|
|
|
|
|
|
|
|
self.sys_exit(err_code)
|
|
self.sys_exit(err_code)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
def check_single_ldap_setting(self, ldap_config, is_multi_ldap=False):
|
|
def check_single_ldap_setting(self, ldap_config, is_multi_ldap=False):
|
|
|
self.print_ldap_setting(ldap_config, is_multi_ldap)
|
|
self.print_ldap_setting(ldap_config, is_multi_ldap)
|
|
|
# Basic validation check for hue.ini's ldap parameters [desktop] > [[ldap]]
|
|
# Basic validation check for hue.ini's ldap parameters [desktop] > [[ldap]]
|
|
@@ -506,7 +505,11 @@ class Command(BaseCommand):
|
|
|
LOG.warning(ldapsearch)
|
|
LOG.warning(ldapsearch)
|
|
|
self.sys_exit(err_code)
|
|
self.sys_exit(err_code)
|
|
|
|
|
|
|
|
- LOG.info('LDAP whoami_s() %s' % (connection.ldap_handle.whoami_s()))
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ LOG.info('LDAP whoami_s() %s' % (connection.ldap_handle.whoami_s()))
|
|
|
|
|
+ except:
|
|
|
|
|
+ LOG.warn('Not able to execute whoami_s() command')
|
|
|
|
|
+
|
|
|
if ldap_config.TEST_LDAP_USER.get() is not None:
|
|
if ldap_config.TEST_LDAP_USER.get() is not None:
|
|
|
err_code = self.find_ldapusers(ldap_config, connection)
|
|
err_code = self.find_ldapusers(ldap_config, connection)
|
|
|
if err_code:
|
|
if err_code:
|