Fix group management issues.

This commit is contained in:
James Valleroy 2015-07-12 14:54:00 -04:00 committed by Sunil Mohan Adapa
parent 32bb08c269
commit 925fbe6cd2
2 changed files with 6 additions and 4 deletions

View File

@ -45,7 +45,7 @@ elif [ $? -eq 65 ]; then
fi
fi
if [ "$groupname" == "admin" ]; then
if [ "$groupname" = "admin" ]; then
# update sudo group if needed
results=$(ldapsearch -Y EXTERNAL -H ldapi:/// -b 'cn=sudo,ou=groups,dc=thisbox' -LLL "(memberUid=$username)")

View File

@ -109,6 +109,11 @@ class UserUpdateForm(forms.ModelForm):
user = super(UserUpdateForm, self).save(commit)
if commit:
output = actions.superuser_run('get-ldap-user-groups',
[self.username])
old_groups = output.strip().split('\n')
old_groups = list(filter(None, old_groups)) # remove blank strings
if self.username != user.get_username():
try:
actions.superuser_run('rename-ldap-user',
@ -117,9 +122,6 @@ class UserUpdateForm(forms.ModelForm):
messages.error(self.request,
_('Renaming LDAP user failed.'))
output = actions.superuser_run('get-ldap-user-groups',
[user.get_username()])
old_groups = output.strip().split('\n')
new_groups = user.groups.values_list('name', flat=True)
for old_group in old_groups:
if old_group not in new_groups: