|
|
|
@ -103,7 +103,7 @@ class UnixGroups(object):
|
|
|
|
|
yield UnixGroup(
|
|
|
|
|
group['cn'][0],
|
|
|
|
|
int(group['gidNumber'][0]),
|
|
|
|
|
group.get('memberUid', []),
|
|
|
|
|
sorted(group.get('memberUid', [])),
|
|
|
|
|
group['description'][0])
|
|
|
|
|
|
|
|
|
|
def search_ldap_group(self, search_filter):
|
|
|
|
@ -554,7 +554,7 @@ class Unix(Ldap):
|
|
|
|
|
login=user, groups=", ".join(groups)))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def modify_user(self, login, pw, gid, shell, visible, lock, comment):
|
|
|
|
|
def modify_user(self, login, pw, pw_delete, gid, shell, visible, lock, comment):
|
|
|
|
|
""""
|
|
|
|
|
Изменить параметры пользователя в LDAP
|
|
|
|
|
"""
|
|
|
|
@ -572,10 +572,14 @@ class Unix(Ldap):
|
|
|
|
|
params['comment'] = comment
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
|
_("Changed comment for user %s") % user.username)
|
|
|
|
|
if pw:
|
|
|
|
|
if pw != UnixUsers.DeletedPassword or pw_delete:
|
|
|
|
|
params['pw'] = pw
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
|
_("Changed password for user %s") % user.username)
|
|
|
|
|
if pw_delete:
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
|
_("Removed password for user %s") % user.username)
|
|
|
|
|
else:
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
|
_("Changed password for user %s") % user.username)
|
|
|
|
|
if shell and user.shell != shell:
|
|
|
|
|
params['shell'] = shell
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
@ -636,9 +640,10 @@ class Unix(Ldap):
|
|
|
|
|
raise UnixError(_("Failed to create user home directory"))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def show_groups(self, fields, count, offset):
|
|
|
|
|
def show_groups(self, groupname, fields, count, offset):
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
|
|
|
|
|
fields = ["ur_unix_group_name"] + list(fields)
|
|
|
|
|
head = [dv.getInfo(x).label for x in fields]
|
|
|
|
|
body = []
|
|
|
|
|
ldap_connect = self.clVars.Get('ldap.cl_ldap_connect')
|
|
|
|
@ -652,12 +657,12 @@ class Unix(Ldap):
|
|
|
|
|
for x in ('cl_unix_group_filter_name',
|
|
|
|
|
'cl_unix_group_filter_id',
|
|
|
|
|
'cl_unix_group_filter_comment',
|
|
|
|
|
'cl_unix_group_filter_users',
|
|
|
|
|
'cl_unix_group_filter_primary'))
|
|
|
|
|
'cl_unix_group_filter_users'))
|
|
|
|
|
filters = [x.test for x in filters if x.enabled()]
|
|
|
|
|
|
|
|
|
|
def all_users(group):
|
|
|
|
|
for user in uu.iterate_ldap_user("gidNumber=%d" % group.gid):
|
|
|
|
|
for user in sorted(uu.iterate_ldap_user("gidNumber=%d" % group.gid),
|
|
|
|
|
key=lambda x: x.username):
|
|
|
|
|
yield "<%s>" % user.username
|
|
|
|
|
for user in group.user_list:
|
|
|
|
|
yield user
|
|
|
|
@ -669,29 +674,47 @@ class Unix(Ldap):
|
|
|
|
|
'ur_unix_group_users': lambda group: ", ".join(all_users(group))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for group in ug.iterate_ldap_group("cn=*", offset, count):
|
|
|
|
|
if all(x(group) for x in filters):
|
|
|
|
|
body.append([variables_mapping.get(x)(group) for x in fields])
|
|
|
|
|
|
|
|
|
|
mapping = {'ur_unix_group_name': 'ur_unix_group_name_exists'}
|
|
|
|
|
|
|
|
|
|
maxi = 0
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
for i, group in enumerate(sorted(
|
|
|
|
|
(group for group in
|
|
|
|
|
ug.iterate_ldap_group("cn=*")
|
|
|
|
|
if all(x(group) for x in filters)),
|
|
|
|
|
key=lambda x: x.group_name)):
|
|
|
|
|
maxi = i
|
|
|
|
|
if offset <= i < offset + count:
|
|
|
|
|
body.append(
|
|
|
|
|
[variables_mapping.get(x)(group) for x in fields])
|
|
|
|
|
except LDAPBadSearchFilter:
|
|
|
|
|
raise UnixError(_("Wrong group pattern"))
|
|
|
|
|
|
|
|
|
|
table_fields = [mapping.get(x, '') for x in fields]
|
|
|
|
|
if not body:
|
|
|
|
|
body = [[]]
|
|
|
|
|
dv.Invalidate('ur_unix_group_count')
|
|
|
|
|
|
|
|
|
|
if any(body):
|
|
|
|
|
head_message = _("Groups")
|
|
|
|
|
elif dv.GetInteger("ur_unix_group_count"):
|
|
|
|
|
head_message = _("Groups not found")
|
|
|
|
|
else:
|
|
|
|
|
head_message = _("No groups")
|
|
|
|
|
self.printTable(
|
|
|
|
|
_("Groups") if any(body) else _("No groups"), head, body,
|
|
|
|
|
fields=table_fields,
|
|
|
|
|
onClick='unix_groupmod' if any(table_fields) else None,
|
|
|
|
|
addAction='unix_groupadd',
|
|
|
|
|
records=self.clVars.Get('core.cl_page_max'))
|
|
|
|
|
head_message, head, body,
|
|
|
|
|
fields=table_fields,
|
|
|
|
|
onClick='unix_groupmod' if any(table_fields) else None,
|
|
|
|
|
addAction='unix_groupadd',
|
|
|
|
|
records=str(maxi))
|
|
|
|
|
if any(body):
|
|
|
|
|
num_page, count_page = getPagesInterval(
|
|
|
|
|
count, offset, int(self.clVars.Get('core.cl_page_max')))
|
|
|
|
|
count, offset, maxi)
|
|
|
|
|
self.printSUCCESS(_('page %d from ') % num_page + str(count_page))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def show_group(self, groupname):
|
|
|
|
|
print groupname
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
list_group_name = sorted(dv.Choice('cl_core_group'))
|
|
|
|
|
|
|
|
|
@ -718,12 +741,16 @@ class Unix(Ldap):
|
|
|
|
|
body.append([varobj.label or "", varval])
|
|
|
|
|
|
|
|
|
|
if body:
|
|
|
|
|
self.printTable(_("Group info"), head, body)
|
|
|
|
|
self.printTable(_("Group info"), head, body,
|
|
|
|
|
onClick="unix_groupmod",
|
|
|
|
|
records="0",
|
|
|
|
|
fields=["ur_unix_group_name_exists:%s" % groupname])
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def show_users(self, login, fields, count, offset):
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
|
|
|
|
|
fields = ["ur_unix_login"] + list(fields)
|
|
|
|
|
head = [dv.getInfo(x).label for x in fields]
|
|
|
|
|
body = []
|
|
|
|
|
ldap_connect = self.clVars.Get('ldap.cl_ldap_connect')
|
|
|
|
@ -765,11 +792,17 @@ class Unix(Ldap):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapping = {'ur_unix_login': 'ur_unix_login_exists'}
|
|
|
|
|
maxi = 0
|
|
|
|
|
try:
|
|
|
|
|
for user in uu.iterate_ldap_user("uid=%s" % login, offset, count):
|
|
|
|
|
if all(x(user) for x in filters):
|
|
|
|
|
for i, user in enumerate(sorted(
|
|
|
|
|
(user for user in uu.iterate_ldap_user("uid=*")
|
|
|
|
|
if all(x(user) for x in filters)),
|
|
|
|
|
key=lambda x: x.username)):
|
|
|
|
|
maxi = i
|
|
|
|
|
if offset <= i < offset + count:
|
|
|
|
|
body.append(
|
|
|
|
|
[variables_mapping.get(x)(user) for x in fields])
|
|
|
|
|
|
|
|
|
|
except LDAPBadSearchFilter:
|
|
|
|
|
raise UnixError(_("Wrong user pattern"))
|
|
|
|
|
table_fields = [mapping.get(x, '') for x in fields]
|
|
|
|
@ -777,15 +810,21 @@ class Unix(Ldap):
|
|
|
|
|
if not body:
|
|
|
|
|
body = [[]]
|
|
|
|
|
dv.Invalidate('ur_unix_user_count')
|
|
|
|
|
self.printTable(_("Users") if any(body) else _("No Users"),
|
|
|
|
|
if any(body):
|
|
|
|
|
head_message = _("Users")
|
|
|
|
|
elif dv.GetInteger("ur_unix_user_count"):
|
|
|
|
|
head_message = _("Users not found")
|
|
|
|
|
else:
|
|
|
|
|
head_message = _("No users")
|
|
|
|
|
self.printTable(head_message,
|
|
|
|
|
head, body,
|
|
|
|
|
fields=table_fields,
|
|
|
|
|
onClick='unix_usermod' if any(table_fields) else None,
|
|
|
|
|
addAction='unix_useradd',
|
|
|
|
|
records=str(self.clVars.Get('unix.ur_unix_user_count')))
|
|
|
|
|
records=str(maxi))
|
|
|
|
|
if any(body):
|
|
|
|
|
num_page, count_page = getPagesInterval(
|
|
|
|
|
count, offset, int(self.clVars.Get('unix.ur_unix_user_count')))
|
|
|
|
|
count, offset, maxi)
|
|
|
|
|
self.printSUCCESS(_('page %d from ') % num_page + str(count_page))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
@ -818,7 +857,10 @@ class Unix(Ldap):
|
|
|
|
|
body.append([varobj.label or "", varval])
|
|
|
|
|
|
|
|
|
|
if body:
|
|
|
|
|
self.printTable(_("User info"), head, body)
|
|
|
|
|
self.printTable(_("User info"), head, body,
|
|
|
|
|
onClick="unix_usermod",
|
|
|
|
|
records="0",
|
|
|
|
|
fields=["ur_unix_login_exists:%s" % user])
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def try_remove_primary_group(self, user, primary_group):
|
|
|
|
|