Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
proto3
Commits
a8125ec6
Commit
a8125ec6
authored
Jul 12, 2017
by
Robin Sonnabend
Browse files
Enabled recursive group membership in AD
/close
#144
parent
cf1b5e99
Changes
1
Hide whitespace changes
Inline
Side-by-side
auth.py
View file @
a8125ec6
...
...
@@ -115,12 +115,17 @@ class ADManager:
obj_def
=
ldap3
.
ObjectDef
(
"user"
,
connection
)
name_filter
=
"cn:={}"
.
format
(
username
)
user_reader
=
ldap3
.
Reader
(
connection
,
obj_def
,
self
.
user_dn
,
name_filter
)
group_def
=
ldap3
.
ObjectDef
(
"group"
,
connection
)
def
_yield_recursive_groups
(
group_dn
):
group_reader
=
ldap3
.
Reader
(
connection
,
group_def
,
group_dn
,
None
)
for
entry
in
group_reader
.
search
():
yield
entry
.
name
.
value
for
child
in
entry
.
memberOf
:
yield
from
_yield_recursive_groups
(
child
)
for
result
in
user_reader
.
search
():
for
group_dn
in
result
.
memberOf
:
group_dn_parts
=
parse_dn
(
group_dn
)
if
len
(
group_dn_parts
)
>=
1
:
key
,
group
,
next_char
=
group_dn_parts
[
0
]
yield
group
yield
from
_yield_recursive_groups
(
group_dn
)
def
all_groups
(
self
):
connection
=
self
.
prepare_connection
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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