Skip to content

Commit 2fb3d5a

Browse files
committed
Add option search_filter to ldap
This patch adds the option to override the search_filter in ldap with an own complex search_filter, because sometimes a single simple argument is not sufficient.
1 parent 43fd132 commit 2fb3d5a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

example/plugins/microservices/ldap_attribute_store.yaml.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ config:
8484

8585
ldap_identifier_attribute: uid
8686

87+
# Override the contructed search_filter with ldap_identifier_attribute
88+
# with an own filter. This allows more komplex queries.
89+
# {0} will be injected with the ordered_identifier_candidates.
90+
search_filter: None
91+
8792
# Whether to clear values for attributes incoming
8893
# to this microservice. Default is no or false.
8994
clear_input_attributes: no

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class LdapAttributeStore(ResponseMicroService):
4646
"clear_input_attributes": False,
4747
"ignore": False,
4848
"ldap_identifier_attribute": None,
49+
"search_filter": None,
4950
"ldap_url": None,
5051
"ldap_to_internal_map": None,
5152
"on_ldap_search_result_empty": None,
@@ -473,8 +474,11 @@ def process(self, context, data):
473474
logger.debug(logline)
474475

475476
for filter_val in filter_values:
476-
ldap_ident_attr = config["ldap_identifier_attribute"]
477-
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
477+
if config["search_filter"]:
478+
search_filter = config["search_filter"].format(filter_val)
479+
else:
480+
ldap_ident_attr = config["ldap_identifier_attribute"]
481+
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
478482
msg = {
479483
"message": "LDAP query with constructed search filter",
480484
"search filter": search_filter,

0 commit comments

Comments
 (0)