From db9118cb7ce2dea08a52c3a0b5ddaa644d14dcde Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 28 Nov 2021 11:11:41 -0600 Subject: [PATCH] Improve admin LDAP user index * Show which domain the current list is for * Render text links as such --- app/controllers/admin/ldap_users_controller.rb | 8 +++----- app/views/admin/ldap_users/index.html.erb | 13 +++++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/ldap_users_controller.rb b/app/controllers/admin/ldap_users_controller.rb index 1dfea57..80f9392 100644 --- a/app/controllers/admin/ldap_users_controller.rb +++ b/app/controllers/admin/ldap_users_controller.rb @@ -4,11 +4,9 @@ class Admin::LdapUsersController < Admin::BaseController def index attributes = %w{dn cn uid mail admin} filter = Net::LDAP::Filter.eq("uid", "*") - if params[:ou] - treebase = "ou=#{params[:ou]},cn=users,dc=kosmos,dc=org" - else - treebase = "ou=kosmos.org,cn=users,dc=kosmos,dc=org" - end + + @ou = params[:ou] || "kosmos.org" + treebase = "ou=#{@ou},cn=users,dc=kosmos,dc=org" entries = ldap_client.search(base: treebase, filter: filter, attributes: attributes) entries.sort_by! { |e| e.cn[0] } diff --git a/app/views/admin/ldap_users/index.html.erb b/app/views/admin/ldap_users/index.html.erb index 705ed5b..930199c 100644 --- a/app/views/admin/ldap_users/index.html.erb +++ b/app/views/admin/ldap_users/index.html.erb @@ -1,8 +1,13 @@ -

LDAP users

+

LDAP users: <%= @ou %>

-