Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
87ee1133
Commit
87ee1133
authored
Apr 13, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Concat AD group recursive member results with reguler member results
parent
faad5120
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
6 deletions
+61
-6
CHANGELOG-EE
CHANGELOG-EE
+1
-0
lib/gitlab/ldap/group.rb
lib/gitlab/ldap/group.rb
+10
-6
spec/lib/gitlab/ldap/group_spec.rb
spec/lib/gitlab/ldap/group_spec.rb
+50
-0
No files found.
CHANGELOG-EE
View file @
87ee1133
...
...
@@ -9,6 +9,7 @@ v 8.7.0 (unreleased)
v 8.6.6
- Fix LDAP group sync regression for groups with member value `uid=<username>` !335
- Concat AD group recursive member results with regular member results
v 8.6.5
- No EE-specific changes
...
...
lib/gitlab/ldap/group.rb
View file @
87ee1133
...
...
@@ -39,23 +39,27 @@ module Gitlab
end
def
member_dns
dns
=
[]
# There's an edge-case with AD where sometimes a recursive search
# doesn't return all users at the top-level. Concat recursive results
# with regular results to be safe. See gitlab-ee#484
if
active_directory?
dns
=
adapter
.
dns_for_filter
(
active_directory_recursive_memberof_filter
)
return
dns
unless
dns
.
empty?
end
if
(
entry
.
respond_to?
:member
)
&&
(
entry
.
respond_to?
:submember
)
entry
.
member
+
entry
.
submember
dns
.
concat
(
entry
.
member
+
entry
.
submember
)
elsif
entry
.
respond_to?
:member
entry
.
member
dns
.
concat
(
entry
.
member
)
elsif
entry
.
respond_to?
:uniquemember
entry
.
uniquemember
dns
.
concat
(
entry
.
uniquemember
)
elsif
entry
.
respond_to?
:memberof
entry
.
memberof
dns
.
concat
(
entry
.
memberof
)
else
Rails
.
logger
.
warn
(
"Could not find member DNs for LDAP group
#{
entry
.
inspect
}
"
)
[]
end
dns
.
uniq
end
private
...
...
spec/lib/gitlab/ldap/group_spec.rb
0 → 100644
View file @
87ee1133
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Group
,
lib:
true
do
describe
'#member_dns'
do
def
ldif
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
<<-
EOS
.
strip_heredoc
dn: cn=ldap_group1,ou=groups,dc=example,dc=com
cn: ldap_group1
description: LDAP Group 1
member: uid=user1,ou=users,dc=example,dc=com
member: uid=user2,ou=users,dc=example,dc=com
member: uid=user3,ou=users,dc=example,dc=com
objectclass: top
objectclass: groupOfNames
EOS
)
end
def
adapter
@adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
(
'ldapmain'
)
end
let
(
:group
)
{
described_class
.
new
(
ldif
,
adapter
)
}
let
(
:recursive_dns
)
do
%w(
uid=user3,ou=users,dc=example,dc=com
uid=user4,ou=users,dc=example,dc=com
uid=user5,ou=users,dc=example,dc=com
)
end
it
'concatenates recursive and regular results and returns uniq'
do
allow
(
group
).
to
receive
(
:active_directory?
).
and_return
(
true
)
allow
(
adapter
).
to
receive
(
:dns_for_filter
).
and_return
(
recursive_dns
)
expect
(
group
.
member_dns
)
.
to
match_array
(
%w(
uid=user1,ou=users,dc=example,dc=com
uid=user2,ou=users,dc=example,dc=com
uid=user3,ou=users,dc=example,dc=com
uid=user4,ou=users,dc=example,dc=com
uid=user5,ou=users,dc=example,dc=com
)
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment