Commit 7ba37d86 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Gitlab::LDAP - ability to collect group members

parent 1e9b2733
......@@ -54,10 +54,10 @@ module Gitlab
end
end
def users(cn = "*")
def users(uid = "*")
options = {
base: config['base'],
filter: Net::LDAP::Filter.eq("cn", cn)
filter: Net::LDAP::Filter.eq("uid", uid)
}
entries = ldap.search(options).select do |entry|
......@@ -69,6 +69,10 @@ module Gitlab
end
end
def user(uid)
users(uid).first
end
private
def config
......
......@@ -26,8 +26,26 @@ module Gitlab
end
def members
member_uids.map do |uid|
adapter.user(uid)
end.compact
end
private
def member_uids
if entry.respond_to? :memberuid
entry.memberuid
else
member_dns.map do |dn|
$1 if dn =~ /uid=([a-zA-Z0-9.-]+)/
end
end.compact
end
def member_dns
if entry.respond_to? :member
entry.meber
entry.member
elsif entry.respond_to? :uniquemember
entry.uniquemember
elsif entry.respond_to? :memberof
......@@ -37,11 +55,13 @@ module Gitlab
end
end
private
def entry
@entry
end
def adapter
@adapter ||= Gitlab::LDAP::Adapter.new
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment