Retrieve only necessary attributes from LDAP server
This commit is contained in:
parent
eebbb159ea
commit
f43d18d46a
@ -52,13 +52,18 @@ class Application
|
|||||||
|
|
||||||
def search_ldap_users
|
def search_ldap_users
|
||||||
ldap_user_conf = @config[:ldap_users]
|
ldap_user_conf = @config[:ldap_users]
|
||||||
|
name_attribute = ldap_user_conf[:name_attribute]
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
res = @ldap.search(:base => ldap_user_conf[:base], :filter => ldap_user_conf[:filter]) do |entry|
|
res = @ldap.search(
|
||||||
name = entry[ldap_user_conf[:name_attribute]].first
|
base: ldap_user_conf[:base],
|
||||||
|
filter: ldap_user_conf[:filter],
|
||||||
|
attributes: [name_attribute, :dn]
|
||||||
|
) do |entry|
|
||||||
|
name = entry[name_attribute].first
|
||||||
|
|
||||||
unless name
|
unless name
|
||||||
log.warn "user attribute #{ldap_user_conf[:name_attribute].inspect} not defined for #{entry.dn}"
|
log.warn "user attribute #{name_attribute.inspect} not defined for #{entry.dn}"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
log.info "found user-dn: #{entry.dn}"
|
log.info "found user-dn: #{entry.dn}"
|
||||||
@ -123,7 +128,11 @@ class Application
|
|||||||
member_attribute = ldap_group_conf[:member_attribute]
|
member_attribute = ldap_group_conf[:member_attribute]
|
||||||
|
|
||||||
groups = []
|
groups = []
|
||||||
res = @ldap.search(:base => ldap_group_conf[:base], :filter => ldap_group_conf[:filter]) do |entry|
|
res = @ldap.search(
|
||||||
|
base: ldap_group_conf[:base],
|
||||||
|
filter: ldap_group_conf[:filter],
|
||||||
|
attributes: [name_attribute, member_attribute, :dn]
|
||||||
|
) do |entry|
|
||||||
name = entry[name_attribute].first
|
name = entry[name_attribute].first
|
||||||
|
|
||||||
unless name
|
unless name
|
||||||
|
Reference in New Issue
Block a user