Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flask-simpleldap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
flask-simpleldap
Commits
353ecf13
Unverified
Commit
353ecf13
authored
6 years ago
by
JM Lopez Lujan
Browse files
Options
Downloads
Patches
Plain Diff
get_object_details to take query_filter and fallback
to LDAP_USER_OBJECT_FILTER or LDAP_GROUP_OBJECT_FILTER fixes #58
parent
c0554780
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
flask_simpleldap/__init__.py
+9
-5
9 additions, 5 deletions
flask_simpleldap/__init__.py
with
9 additions
and
5 deletions
flask_simpleldap/__init__.py
+
9
−
5
View file @
353ecf13
...
...
@@ -155,11 +155,13 @@ class LDAP(object):
except
ldap
.
LDAPError
:
return
def
get_object_details
(
self
,
user
=
None
,
group
=
None
,
dn_only
=
False
):
def
get_object_details
(
self
,
user
=
None
,
group
=
None
,
query_filter
=
None
,
dn_only
=
False
):
"""
Returns a ``dict`` with the object
'
s (user or group) details.
:param str user: Username of the user object you want details for.
:param str group: Name of the group object you want details for.
:param str query_filter: If included, will be used to query object.
:param bool dn_only: If we should only retrieve the object
'
s
distinguished name or not. Default: ``False``.
"""
...
...
@@ -169,13 +171,15 @@ class LDAP(object):
if
user
is
not
None
:
if
not
dn_only
:
fields
=
current_app
.
config
[
'
LDAP_USER_FIELDS
'
]
query
=
ldap_filter
.
filter_format
(
current_app
.
config
[
'
LDAP_USER_OBJECT_FILTER
'
],
(
user
,))
query_filter
=
query_filter
or
\
current_app
.
config
[
'
LDAP_USER_OBJECT_FILTER
'
]
query
=
ldap_filter
.
filter_format
(
query_filter
,
(
user
,))
elif
group
is
not
None
:
if
not
dn_only
:
fields
=
current_app
.
config
[
'
LDAP_GROUP_FIELDS
'
]
query
=
ldap_filter
.
filter_format
(
current_app
.
config
[
'
LDAP_GROUP_OBJECT_FILTER
'
],
(
group
,))
query_filter
=
query_filter
or
\
current_app
.
config
[
'
LDAP_GROUP_OBJECT_FILTER
'
]
query
=
ldap_filter
.
filter_format
(
query_filter
,
(
group
,))
conn
=
self
.
bind
try
:
records
=
conn
.
search_s
(
current_app
.
config
[
'
LDAP_BASE_DN
'
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment