mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
users: Show if user is also an LDAP user.
This commit is contained in:
parent
aece3d7ee0
commit
219c3f4b06
27
actions/check-ldap-user-exists
Executable file
27
actions/check-ldap-user-exists
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This file is part of Plinth.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
username="$1"
|
||||||
|
|
||||||
|
results=$(ldapsearch -x -D 'cn=admin,dc=thisbox' -w $(sudo cat /var/lib/plinth/ldap-admin) -b 'ou=users,dc=thisbox' -LLL "(uid=$username)" uid)
|
||||||
|
|
||||||
|
if [ -z "$results" ]; then
|
||||||
|
echo "User does not exist"
|
||||||
|
else
|
||||||
|
echo "User exists"
|
||||||
|
fi
|
||||||
@ -52,6 +52,10 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if is_ldap_user %}
|
||||||
|
<p>This user is also an LDAP user.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary" value="Save Changes"/>
|
<input type="submit" class="btn btn-primary" value="Save Changes"/>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -90,6 +90,8 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
|
|||||||
context = super(UserUpdate, self).get_context_data(**kwargs)
|
context = super(UserUpdate, self).get_context_data(**kwargs)
|
||||||
output = actions.run('check-user-exists', [self.object.username])
|
output = actions.run('check-user-exists', [self.object.username])
|
||||||
context['is_posix_user'] = 'User exists' in output
|
context['is_posix_user'] = 'User exists' in output
|
||||||
|
output = actions.run('check-ldap-user-exists', [self.object.username])
|
||||||
|
context['is_ldap_user'] = 'User exists' in output
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user