Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-ldapserver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uffd
python-ldapserver
Commits
48d92133
Commit
48d92133
authored
3 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
More compact INFO-level logging of SEARCH operations
parent
0697ecf3
No related branches found
No related tags found
No related merge requests found
Pipeline
#8356
passed
3 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ldapserver/ldap.py
+22
-15
22 additions, 15 deletions
ldapserver/ldap.py
ldapserver/server.py
+6
-5
6 additions, 5 deletions
ldapserver/server.py
with
28 additions
and
20 deletions
ldapserver/ldap.py
+
22
−
15
View file @
48d92133
...
@@ -42,7 +42,7 @@ class Filter(asn1.Choice, ABC):
...
@@ -42,7 +42,7 @@ class Filter(asn1.Choice, ABC):
'''
Base class for filters in SEARCH operations
'''
'''
Base class for filters in SEARCH operations
'''
@abstractmethod
@abstractmethod
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
raise
NotImplementedError
()
raise
NotImplementedError
()
class
FilterAnd
(
asn1
.
Wrapper
,
Filter
):
class
FilterAnd
(
asn1
.
Wrapper
,
Filter
):
...
@@ -64,8 +64,8 @@ class FilterAnd(asn1.Wrapper, Filter):
...
@@ -64,8 +64,8 @@ class FilterAnd(asn1.Wrapper, Filter):
def
__init__
(
self
,
filters
=
None
):
def
__init__
(
self
,
filters
=
None
):
super
().
__init__
(
filters
=
filters
)
super
().
__init__
(
filters
=
filters
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(&%s)
'
%
(
''
.
join
([
subfilter
.
get_filter_string
(
)
for
subfilter
in
self
.
filters
]))
return
'
(&%s)
'
%
(
''
.
join
([
str
(
subfilter
)
for
subfilter
in
self
.
filters
]))
class
FilterOr
(
asn1
.
Wrapper
,
Filter
):
class
FilterOr
(
asn1
.
Wrapper
,
Filter
):
'''
OR conjunction of multiple filters ``(|filters...)``
'''
OR conjunction of multiple filters ``(|filters...)``
...
@@ -86,8 +86,8 @@ class FilterOr(asn1.Wrapper, Filter):
...
@@ -86,8 +86,8 @@ class FilterOr(asn1.Wrapper, Filter):
def
__init__
(
self
,
filters
=
None
):
def
__init__
(
self
,
filters
=
None
):
super
().
__init__
(
filters
=
filters
)
super
().
__init__
(
filters
=
filters
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(|%s)
'
%
(
''
.
join
([
subfilter
.
get_filter_string
(
)
for
subfilter
in
self
.
filters
]))
return
'
(|%s)
'
%
(
''
.
join
([
str
(
subfilter
)
for
subfilter
in
self
.
filters
]))
class
FilterNot
(
asn1
.
Sequence
,
Filter
):
class
FilterNot
(
asn1
.
Sequence
,
Filter
):
'''
Negation of a filter ``(!filter)``
'''
Negation of a filter ``(!filter)``
...
@@ -107,8 +107,8 @@ class FilterNot(asn1.Sequence, Filter):
...
@@ -107,8 +107,8 @@ class FilterNot(asn1.Sequence, Filter):
def
__init__
(
self
,
filter
=
None
):
def
__init__
(
self
,
filter
=
None
):
super
().
__init__
(
filter
=
filter
)
super
().
__init__
(
filter
=
filter
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(!%s)
'
%
self
.
filter
.
get_filter_string
(
)
return
'
(!%s)
'
%
str
(
self
.
filter
)
class
FilterEqual
(
asn1
.
Sequence
,
Filter
):
class
FilterEqual
(
asn1
.
Sequence
,
Filter
):
'''
Attribute equal filter ``(attribute=value)``
'''
Attribute equal filter ``(attribute=value)``
...
@@ -130,7 +130,7 @@ class FilterEqual(asn1.Sequence, Filter):
...
@@ -130,7 +130,7 @@ class FilterEqual(asn1.Sequence, Filter):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(%s=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
return
'
(%s=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
class
Substring
(
asn1
.
Choice
,
ABC
):
class
Substring
(
asn1
.
Choice
,
ABC
):
...
@@ -200,7 +200,7 @@ class FilterSubstrings(asn1.Sequence, Filter):
...
@@ -200,7 +200,7 @@ class FilterSubstrings(asn1.Sequence, Filter):
return
None
return
None
return
results
[
0
]
return
results
[
0
]
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
substrings
=
[
self
.
initial_substring
or
b
''
]
+
self
.
any_substrings
+
[
self
.
final_substring
or
b
''
]
substrings
=
[
self
.
initial_substring
or
b
''
]
+
self
.
any_substrings
+
[
self
.
final_substring
or
b
''
]
value
=
'
*
'
.
join
(
map
(
escape_filter_assertionvalue
,
substrings
))
value
=
'
*
'
.
join
(
map
(
escape_filter_assertionvalue
,
substrings
))
return
f
'
(
{
self
.
attribute
}
=
{
value
}
)
'
return
f
'
(
{
self
.
attribute
}
=
{
value
}
)
'
...
@@ -218,7 +218,7 @@ class FilterGreaterOrEqual(asn1.Sequence, Filter):
...
@@ -218,7 +218,7 @@ class FilterGreaterOrEqual(asn1.Sequence, Filter):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(%s>=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
return
'
(%s>=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
class
FilterLessOrEqual
(
asn1
.
Sequence
,
Filter
):
class
FilterLessOrEqual
(
asn1
.
Sequence
,
Filter
):
...
@@ -234,7 +234,7 @@ class FilterLessOrEqual(asn1.Sequence, Filter):
...
@@ -234,7 +234,7 @@ class FilterLessOrEqual(asn1.Sequence, Filter):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(%s<=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
return
'
(%s<=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
class
FilterPresent
(
asn1
.
Wrapper
,
Filter
):
class
FilterPresent
(
asn1
.
Wrapper
,
Filter
):
...
@@ -253,7 +253,7 @@ class FilterPresent(asn1.Wrapper, Filter):
...
@@ -253,7 +253,7 @@ class FilterPresent(asn1.Wrapper, Filter):
def
__init__
(
self
,
attribute
=
None
):
def
__init__
(
self
,
attribute
=
None
):
super
().
__init__
(
attribute
=
attribute
)
super
().
__init__
(
attribute
=
attribute
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(%s=*)
'
%
(
self
.
attribute
)
return
'
(%s=*)
'
%
(
self
.
attribute
)
class
FilterApproxMatch
(
asn1
.
Sequence
,
Filter
):
class
FilterApproxMatch
(
asn1
.
Sequence
,
Filter
):
...
@@ -269,7 +269,7 @@ class FilterApproxMatch(asn1.Sequence, Filter):
...
@@ -269,7 +269,7 @@ class FilterApproxMatch(asn1.Sequence, Filter):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
def
__init__
(
self
,
attribute
=
None
,
value
=
None
):
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
super
().
__init__
(
attribute
=
attribute
,
value
=
value
)
def
get_filter
_str
ing
(
self
):
def
_
_str
__
(
self
):
return
'
(%s~=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
return
'
(%s~=%s)
'
%
(
self
.
attribute
,
escape_filter_assertionvalue
(
self
.
value
))
class
FilterExtensibleMatch
(
asn1
.
Sequence
,
Filter
):
class
FilterExtensibleMatch
(
asn1
.
Sequence
,
Filter
):
...
@@ -286,8 +286,15 @@ class FilterExtensibleMatch(asn1.Sequence, Filter):
...
@@ -286,8 +286,15 @@ class FilterExtensibleMatch(asn1.Sequence, Filter):
matchValue
:
bytes
matchValue
:
bytes
dnAttributes
:
bool
dnAttributes
:
bool
def
get_filter_string
(
self
):
def
__str__
(
self
):
return
'
(%s:%s:=%s)
'
%
(
self
.
matchingRule
,
self
.
type
,
escape_filter_assertionvalue
(
self
.
matchValue
))
parts
=
[]
if
self
.
type
is
not
None
:
parts
.
append
(
self
.
type
)
if
self
.
dnAttributes
:
parts
.
append
(
'
dn
'
)
if
self
.
matchingRule
is
not
None
:
parts
.
append
(
self
.
matchingRule
)
return
'
(%s:=%s)
'
%
(
'
:
'
.
join
(
parts
),
escape_filter_assertionvalue
(
self
.
matchValue
))
class
SearchScope
(
enum
.
Enum
):
class
SearchScope
(
enum
.
Enum
):
'''
:any:`enum.Enum` of `scope` values in SEARCH operations
'''
'''
:any:`enum.Enum` of `scope` values in SEARCH operations
'''
...
...
This diff is collapsed.
Click to expand it.
ldapserver/server.py
+
6
−
5
View file @
48d92133
...
@@ -459,12 +459,12 @@ class LDAPRequestHandler(BaseLDAPRequestHandler):
...
@@ -459,12 +459,12 @@ class LDAPRequestHandler(BaseLDAPRequestHandler):
self
.
__paged_searches
[
cookie
]
=
iterator
,
op
self
.
__paged_searches
[
cookie
]
=
iterator
,
op
yield
ldap
.
SearchResultDone
(
ldap
.
LDAPResultCode
.
success
),
[
build_control
(
cookie
=
cookie
)]
yield
ldap
.
SearchResultDone
(
ldap
.
LDAPResultCode
.
success
),
[
build_control
(
cookie
=
cookie
)]
time_end
=
time
.
perf_counter
()
time_end
=
time
.
perf_counter
()
self
.
logger
.
info
(
'
SEARCH done page cookie=%r entries=%d duration_seconds=%.3f
'
,
cookie
,
entries
,
time_end
-
time_start
)
self
.
logger
.
info
(
'
SEARCH dn=%r dn_scope=%s filter=%s attributes=%r page_cookie=%r entries=%d duration_seconds=%.3f
'
,
op
.
baseObject
,
op
.
scope
.
name
,
op
.
filter
,
'
'
.
join
(
op
.
attributes
),
cookie
,
entries
,
time_end
-
time_start
)
def
handle_search
(
self
,
op
,
controls
=
None
):
def
handle_search
(
self
,
op
,
controls
=
None
):
self
.
logger
.
info
(
'
SEARCH request dn=%r dn_scope=%s filter=%r, attributes=%r
'
,
self
.
logger
.
debug
(
'
SEARCH request dn=%r dn_scope=%s filter=%r attributes=%r
'
,
op
.
baseObject
,
op
.
scope
.
name
,
op
.
filter
.
get_filter_string
(),
op
.
baseObject
,
op
.
scope
.
name
,
str
(
op
.
filter
),
'
'
.
join
(
op
.
attributes
))
'
'
.
join
(
op
.
attributes
))
paged_control
=
None
paged_control
=
None
if
self
.
supports_paged_results
:
if
self
.
supports_paged_results
:
paged_control
,
controls
=
pop_control
(
controls
,
ldap
.
PAGED_RESULTS_OID
)
paged_control
,
controls
=
pop_control
(
controls
,
ldap
.
PAGED_RESULTS_OID
)
...
@@ -482,7 +482,8 @@ class LDAPRequestHandler(BaseLDAPRequestHandler):
...
@@ -482,7 +482,8 @@ class LDAPRequestHandler(BaseLDAPRequestHandler):
yield
entry
yield
entry
yield
ldap
.
SearchResultDone
(
ldap
.
LDAPResultCode
.
success
)
yield
ldap
.
SearchResultDone
(
ldap
.
LDAPResultCode
.
success
)
time_end
=
time
.
perf_counter
()
time_end
=
time
.
perf_counter
()
self
.
logger
.
info
(
'
SEARCH done entries=%d duration_seconds=%.3f
'
,
entries
,
time_end
-
time_start
)
self
.
logger
.
info
(
'
SEARCH dn=%r dn_scope=%s filter=
\'
%s
\'
attributes=%r entries=%d duration_seconds=%.3f
'
,
op
.
baseObject
,
op
.
scope
.
name
,
op
.
filter
,
'
'
.
join
(
op
.
attributes
),
entries
,
time_end
-
time_start
)
def
do_search
(
self
,
baseobj
,
scope
,
filterobj
):
def
do_search
(
self
,
baseobj
,
scope
,
filterobj
):
'''
Do LDAP SEARCH operation
'''
Do LDAP SEARCH operation
...
...
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