|
@@ -15,6 +15,8 @@
|
|
|
# See the License for the specific language governing permissions and
|
|
# See the License for the specific language governing permissions and
|
|
|
# limitations under the License.
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
+from __future__ import absolute_import
|
|
|
|
|
+from builtins import map
|
|
|
import pwd
|
|
import pwd
|
|
|
import grp
|
|
import grp
|
|
|
import logging
|
|
import logging
|
|
@@ -27,8 +29,8 @@ from axes.models import AccessAttempt
|
|
|
from axes.utils import reset
|
|
from axes.utils import reset
|
|
|
|
|
|
|
|
import ldap
|
|
import ldap
|
|
|
-import ldap_access
|
|
|
|
|
-from ldap_access import LdapBindException, LdapSearchException
|
|
|
|
|
|
|
+from useradmin import ldap_access
|
|
|
|
|
+from useradmin.ldap_access import LdapBindException, LdapSearchException
|
|
|
|
|
|
|
|
from django.contrib.auth.models import User, Group
|
|
from django.contrib.auth.models import User, Group
|
|
|
from django.urls import reverse
|
|
from django.urls import reverse
|
|
@@ -326,7 +328,7 @@ def edit_user(request, username=None):
|
|
|
try:
|
|
try:
|
|
|
reset(username=username)
|
|
reset(username=username)
|
|
|
request.info(_('Successfully unlocked account for user: %s') % username)
|
|
request.info(_('Successfully unlocked account for user: %s') % username)
|
|
|
- except Exception, e:
|
|
|
|
|
|
|
+ except Exception as e:
|
|
|
raise PopupException(_('Failed to reset login attempts for %s: %s') % (username, str(e)))
|
|
raise PopupException(_('Failed to reset login attempts for %s: %s') % (username, str(e)))
|
|
|
finally:
|
|
finally:
|
|
|
__users_lock.release()
|
|
__users_lock.release()
|
|
@@ -335,7 +337,7 @@ def edit_user(request, username=None):
|
|
|
if form.cleaned_data.get('ensure_home_directory'):
|
|
if form.cleaned_data.get('ensure_home_directory'):
|
|
|
try:
|
|
try:
|
|
|
ensure_home_directory(request.fs, instance)
|
|
ensure_home_directory(request.fs, instance)
|
|
|
- except (IOError, WebHdfsException), e:
|
|
|
|
|
|
|
+ except (IOError, WebHdfsException) as e:
|
|
|
request.error(_('Cannot make home directory for user %s.') % instance.username)
|
|
request.error(_('Cannot make home directory for user %s.') % instance.username)
|
|
|
else:
|
|
else:
|
|
|
updated = True
|
|
updated = True
|
|
@@ -399,7 +401,7 @@ def edit_user(request, username=None):
|
|
|
})
|
|
})
|
|
|
else:
|
|
else:
|
|
|
if request.method == 'POST' and is_embeddable:
|
|
if request.method == 'POST' and is_embeddable:
|
|
|
- return JsonResponse({'status': -1, 'errors': [{'id': f.id_for_label, 'message': map(antixss, f.errors)} for f in form if f.errors]})
|
|
|
|
|
|
|
+ return JsonResponse({'status': -1, 'errors': [{'id': f.id_for_label, 'message': list(map(antixss, f.errors))} for f in form if f.errors]})
|
|
|
else:
|
|
else:
|
|
|
return render('edit_user.mako', request, {
|
|
return render('edit_user.mako', request, {
|
|
|
'form': form,
|
|
'form': form,
|
|
@@ -559,10 +561,10 @@ def add_ldap_users(request):
|
|
|
failed_ldap_users = []
|
|
failed_ldap_users = []
|
|
|
connection = ldap_access.get_connection_from_server(server)
|
|
connection = ldap_access.get_connection_from_server(server)
|
|
|
users = import_ldap_users(connection, username_pattern, False, import_by_dn, failed_users=failed_ldap_users)
|
|
users = import_ldap_users(connection, username_pattern, False, import_by_dn, failed_users=failed_ldap_users)
|
|
|
- except (ldap.LDAPError, LdapBindException), e:
|
|
|
|
|
|
|
+ except (ldap.LDAPError, LdapBindException) as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
|
- except ValidationError, e:
|
|
|
|
|
|
|
+ except ValidationError as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was a problem with some of the LDAP information: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was a problem with some of the LDAP information: %s')) % str(e))
|
|
|
|
|
|
|
@@ -570,7 +572,7 @@ def add_ldap_users(request):
|
|
|
for user in users:
|
|
for user in users:
|
|
|
try:
|
|
try:
|
|
|
ensure_home_directory(request.fs, user)
|
|
ensure_home_directory(request.fs, user)
|
|
|
- except (IOError, WebHdfsException), e:
|
|
|
|
|
|
|
+ except (IOError, WebHdfsException) as e:
|
|
|
request.error(_("Cannot make home directory for user %s.") % user.username)
|
|
request.error(_("Cannot make home directory for user %s.") % user.username)
|
|
|
|
|
|
|
|
if not users:
|
|
if not users:
|
|
@@ -636,10 +638,10 @@ def add_ldap_groups(request):
|
|
|
groups = import_ldap_groups(connection, groupname_pattern, import_members=import_members,
|
|
groups = import_ldap_groups(connection, groupname_pattern, import_members=import_members,
|
|
|
import_members_recursive=import_members_recursive, sync_users=True,
|
|
import_members_recursive=import_members_recursive, sync_users=True,
|
|
|
import_by_dn=import_by_dn, failed_users=failed_ldap_users)
|
|
import_by_dn=import_by_dn, failed_users=failed_ldap_users)
|
|
|
- except (ldap.LDAPError, LdapBindException), e:
|
|
|
|
|
|
|
+ except (ldap.LDAPError, LdapBindException) as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
|
- except ValidationError, e:
|
|
|
|
|
|
|
+ except ValidationError as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was a problem with some of the LDAP information: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was a problem with some of the LDAP information: %s')) % str(e))
|
|
|
|
|
|
|
@@ -651,7 +653,7 @@ def add_ldap_groups(request):
|
|
|
for user in unique_users:
|
|
for user in unique_users:
|
|
|
try:
|
|
try:
|
|
|
ensure_home_directory(request.fs, user)
|
|
ensure_home_directory(request.fs, user)
|
|
|
- except (IOError, WebHdfsException), e:
|
|
|
|
|
|
|
+ except (IOError, WebHdfsException) as e:
|
|
|
raise PopupException(_("Exception creating home directory for LDAP user %s in group %s.") % (user, group), detail=e)
|
|
raise PopupException(_("Exception creating home directory for LDAP user %s in group %s.") % (user, group), detail=e)
|
|
|
|
|
|
|
|
if groups:
|
|
if groups:
|
|
@@ -708,7 +710,7 @@ def sync_ldap_users_groups(request):
|
|
|
server = form.cleaned_data.get('server')
|
|
server = form.cleaned_data.get('server')
|
|
|
try:
|
|
try:
|
|
|
connection = ldap_access.get_connection_from_server(server)
|
|
connection = ldap_access.get_connection_from_server(server)
|
|
|
- except (ldap.LDAPError, LdapBindException), e:
|
|
|
|
|
|
|
+ except (ldap.LDAPError, LdapBindException) as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
|
|
|
|
|
@@ -744,7 +746,7 @@ def sync_ldap_users_and_groups(connection, is_ensuring_home_directory=False, fs=
|
|
|
try:
|
|
try:
|
|
|
users = sync_ldap_users(connection, failed_users=failed_users)
|
|
users = sync_ldap_users(connection, failed_users=failed_users)
|
|
|
groups = sync_ldap_groups(connection, failed_users=failed_users)
|
|
groups = sync_ldap_groups(connection, failed_users=failed_users)
|
|
|
- except (ldap.LDAPError, LdapBindException), e:
|
|
|
|
|
|
|
+ except (ldap.LDAPError, LdapBindException) as e:
|
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
LOG.error("LDAP Exception: %s" % smart_str(e))
|
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
raise PopupException(smart_str(_('There was an error when communicating with LDAP: %s')) % str(e))
|
|
|
|
|
|
|
@@ -753,7 +755,7 @@ def sync_ldap_users_and_groups(connection, is_ensuring_home_directory=False, fs=
|
|
|
for user in users:
|
|
for user in users:
|
|
|
try:
|
|
try:
|
|
|
ensure_home_directory(fs, user)
|
|
ensure_home_directory(fs, user)
|
|
|
- except (IOError, WebHdfsException), e:
|
|
|
|
|
|
|
+ except (IOError, WebHdfsException) as e:
|
|
|
raise PopupException(_("The import may not be complete, sync again."), detail=e)
|
|
raise PopupException(_("The import may not be complete, sync again."), detail=e)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -813,7 +815,7 @@ def ensure_home_directory(fs, user):
|
|
|
home_directory = userprofile.home_directory.split('@')[0]
|
|
home_directory = userprofile.home_directory.split('@')[0]
|
|
|
|
|
|
|
|
if userprofile is not None and userprofile.home_directory:
|
|
if userprofile is not None and userprofile.home_directory:
|
|
|
- if not isinstance(home_directory, unicode):
|
|
|
|
|
|
|
+ if not isinstance(home_directory, str):
|
|
|
home_directory = home_directory.decode("utf-8")
|
|
home_directory = home_directory.decode("utf-8")
|
|
|
fs.do_as_user(username, fs.create_home_dir, home_directory)
|
|
fs.do_as_user(username, fs.create_home_dir, home_directory)
|
|
|
else:
|
|
else:
|
|
@@ -834,7 +836,7 @@ def sync_unix_users_and_groups(min_uid, max_uid, min_gid, max_gid, check_shell):
|
|
|
__users_lock.acquire()
|
|
__users_lock.acquire()
|
|
|
__groups_lock.acquire()
|
|
__groups_lock.acquire()
|
|
|
# Import groups
|
|
# Import groups
|
|
|
- for name, group in hadoop_groups.iteritems():
|
|
|
|
|
|
|
+ for name, group in hadoop_groups.items():
|
|
|
try:
|
|
try:
|
|
|
if len(group.gr_mem) != 0:
|
|
if len(group.gr_mem) != 0:
|
|
|
hue_group = Group.objects.get(name=name)
|
|
hue_group = Group.objects.get(name=name)
|
|
@@ -854,7 +856,7 @@ def sync_unix_users_and_groups(min_uid, max_uid, min_gid, max_gid, check_shell):
|
|
|
# Now let's import the users
|
|
# Now let's import the users
|
|
|
hadoop_users = dict((user.pw_name, user) for user in pwd.getpwall() \
|
|
hadoop_users = dict((user.pw_name, user) for user in pwd.getpwall() \
|
|
|
if (user.pw_uid >= min_uid and user.pw_uid < max_uid) or user.pw_name in grp.getgrnam('hadoop').gr_mem)
|
|
if (user.pw_uid >= min_uid and user.pw_uid < max_uid) or user.pw_name in grp.getgrnam('hadoop').gr_mem)
|
|
|
- for username, user in hadoop_users.iteritems():
|
|
|
|
|
|
|
+ for username, user in hadoop_users.items():
|
|
|
try:
|
|
try:
|
|
|
if check_shell:
|
|
if check_shell:
|
|
|
pw_shell = user.pw_shell
|
|
pw_shell = user.pw_shell
|
|
@@ -904,7 +906,7 @@ def _import_ldap_users(connection, username_pattern, sync_groups=False, import_b
|
|
|
user_info = None
|
|
user_info = None
|
|
|
try:
|
|
try:
|
|
|
user_info = connection.find_users(username_pattern, find_by_dn=import_by_dn)
|
|
user_info = connection.find_users(username_pattern, find_by_dn=import_by_dn)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
|
if not user_info:
|
|
if not user_info:
|
|
@@ -1020,12 +1022,12 @@ def _import_ldap_members(connection, group, ldap_info, count=0, max_count=1, fai
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
users_info = connection.find_users_of_group(ldap_info['dn'])
|
|
users_info = connection.find_users_of_group(ldap_info['dn'])
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users of group: %s" % e)
|
|
LOG.warn("Failed to find LDAP users of group: %s" % e)
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
groups_info = connection.find_groups_of_group(ldap_info['dn'])
|
|
groups_info = connection.find_groups_of_group(ldap_info['dn'])
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP groups of group: %s" % e)
|
|
LOG.warn("Failed to find LDAP groups of group: %s" % e)
|
|
|
|
|
|
|
|
posix_members = ldap_info['posix_members']
|
|
posix_members = ldap_info['posix_members']
|
|
@@ -1051,13 +1053,13 @@ def _import_ldap_members(connection, group, ldap_info, count=0, max_count=1, fai
|
|
|
user_info = None
|
|
user_info = None
|
|
|
try:
|
|
try:
|
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
|
|
|
|
|
|
if user_info:
|
|
if user_info:
|
|
|
users = _import_ldap_users_info(connection, user_info, failed_users=failed_users)
|
|
users = _import_ldap_users_info(connection, user_info, failed_users=failed_users)
|
|
|
if users:
|
|
if users:
|
|
|
- LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (str(posix_member), str(users), str(group.name)))
|
|
|
|
|
|
|
+ LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
group.user_set.add(*users)
|
|
group.user_set.add(*users)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1070,12 +1072,12 @@ def _sync_ldap_members(connection, group, ldap_info, count=0, max_count=1, faile
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
users_info = connection.find_users_of_group(ldap_info['dn'])
|
|
users_info = connection.find_users_of_group(ldap_info['dn'])
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users of group: %s" % e)
|
|
LOG.warn("Failed to find LDAP users of group: %s" % e)
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
groups_info = connection.find_groups_of_group(ldap_info['dn'])
|
|
groups_info = connection.find_groups_of_group(ldap_info['dn'])
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP groups of group: %s" % e)
|
|
LOG.warn("Failed to find LDAP groups of group: %s" % e)
|
|
|
|
|
|
|
|
posix_members = ldap_info['posix_members']
|
|
posix_members = ldap_info['posix_members']
|
|
@@ -1102,7 +1104,7 @@ def _sync_ldap_members(connection, group, ldap_info, count=0, max_count=1, faile
|
|
|
users_info = []
|
|
users_info = []
|
|
|
try:
|
|
try:
|
|
|
users_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
users_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
|
|
|
|
|
|
for user_info in users_info:
|
|
for user_info in users_info:
|
|
@@ -1130,7 +1132,7 @@ def _import_ldap_nested_groups(connection, groupname_pattern, import_members=Fal
|
|
|
group_info = None
|
|
group_info = None
|
|
|
try:
|
|
try:
|
|
|
group_info = connection.find_groups(groupname_pattern, find_by_dn=import_by_dn, scope=scope)
|
|
group_info = connection.find_groups(groupname_pattern, find_by_dn=import_by_dn, scope=scope)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP group: %s" % e)
|
|
LOG.warn("Failed to find LDAP group: %s" % e)
|
|
|
|
|
|
|
|
if not group_info:
|
|
if not group_info:
|
|
@@ -1185,7 +1187,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
group_info = None
|
|
group_info = None
|
|
|
try:
|
|
try:
|
|
|
group_info = connection.find_groups(groupname_pattern, find_by_dn=import_by_dn, scope=scope)
|
|
group_info = connection.find_groups(groupname_pattern, find_by_dn=import_by_dn, scope=scope)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Could not find LDAP group: %s" % e)
|
|
LOG.warn("Could not find LDAP group: %s" % e)
|
|
|
|
|
|
|
|
if not group_info:
|
|
if not group_info:
|
|
@@ -1216,7 +1218,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
group_info = []
|
|
group_info = []
|
|
|
try:
|
|
try:
|
|
|
group_info = connection.find_groups(ldap_info['dn'], find_by_dn=True)
|
|
group_info = connection.find_groups(ldap_info['dn'], find_by_dn=True)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP group: %s" % e)
|
|
LOG.warn("Failed to find LDAP group: %s" % e)
|
|
|
|
|
|
|
|
for sub_ldap_info in group_info:
|
|
for sub_ldap_info in group_info:
|
|
@@ -1233,7 +1235,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
user_info = []
|
|
user_info = []
|
|
|
try:
|
|
try:
|
|
|
user_info = connection.find_users(member, find_by_dn=True)
|
|
user_info = connection.find_users(member, find_by_dn=True)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
|
if user_info is None:
|
|
if user_info is None:
|
|
@@ -1247,7 +1249,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
validate_username(ldap_info['username'])
|
|
validate_username(ldap_info['username'])
|
|
|
user = ldap_access.get_ldap_user(username=ldap_info['username'])
|
|
user = ldap_access.get_ldap_user(username=ldap_info['username'])
|
|
|
group.user_set.add(user)
|
|
group.user_set.add(user)
|
|
|
- except ValidationError, e:
|
|
|
|
|
|
|
+ except ValidationError as e:
|
|
|
if failed_users is None:
|
|
if failed_users is None:
|
|
|
failed_users = []
|
|
failed_users = []
|
|
|
failed_users.append(ldap_info['username'])
|
|
failed_users.append(ldap_info['username'])
|
|
@@ -1260,19 +1262,19 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
if posix_members:
|
|
if posix_members:
|
|
|
if import_members:
|
|
if import_members:
|
|
|
for posix_member in posix_members:
|
|
for posix_member in posix_members:
|
|
|
- LOG.debug("Importing user %s" % str(posix_member))
|
|
|
|
|
|
|
+ LOG.debug("Importing user %s" % smart_str(posix_member))
|
|
|
# posixGroup class defines 'memberUid' to be login names,
|
|
# posixGroup class defines 'memberUid' to be login names,
|
|
|
# which are defined by 'uid'.
|
|
# which are defined by 'uid'.
|
|
|
user_info = None
|
|
user_info = None
|
|
|
try:
|
|
try:
|
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
|
if user_info:
|
|
if user_info:
|
|
|
users = _import_ldap_users_info(connection, user_info, import_by_dn=False, failed_users=failed_users)
|
|
users = _import_ldap_users_info(connection, user_info, import_by_dn=False, failed_users=failed_users)
|
|
|
if users:
|
|
if users:
|
|
|
- LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (str(posix_member), str(users), str(group.name)))
|
|
|
|
|
|
|
+ LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
group.user_set.add(*users)
|
|
group.user_set.add(*users)
|
|
|
|
|
|
|
|
if sync_users:
|
|
if sync_users:
|
|
@@ -1280,7 +1282,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
user_info = []
|
|
user_info = []
|
|
|
try:
|
|
try:
|
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
- except LdapSearchException, e:
|
|
|
|
|
|
|
+ except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
|
if len(user_info) > 1:
|
|
if len(user_info) > 1:
|
|
@@ -1291,7 +1293,7 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
validate_username(ldap_info['username'])
|
|
validate_username(ldap_info['username'])
|
|
|
user = ldap_access.get_ldap_user(username=ldap_info['username'])
|
|
user = ldap_access.get_ldap_user(username=ldap_info['username'])
|
|
|
group.user_set.add(user)
|
|
group.user_set.add(user)
|
|
|
- except ValidationError, e:
|
|
|
|
|
|
|
+ except ValidationError as e:
|
|
|
if failed_users is None:
|
|
if failed_users is None:
|
|
|
failed_users = []
|
|
failed_users = []
|
|
|
failed_users.append(ldap_info['username'])
|
|
failed_users.append(ldap_info['username'])
|