Skip to content

Commit

Permalink
Merge pull request #100 from CodethinkLabs/bobclough/ldap-add-search-…
Browse files Browse the repository at this point in the history
…filters

LDAP3: Allow the user to set the search filter.
  • Loading branch information
thinkl33t authored Dec 6, 2023
2 parents 7d8d5ac + 1b49689 commit 1d13021
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lifecycle/source_ldap3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ class SourceLDAP3(SourceBase):
"bind_password",
"anonymous_bind",
"use_ssl",
"search_filter",
"group_search_filter",
}
default_config = {
"anonymous_bind": False,
"use_ssl": True,
"search_filter": "(objectclass=organizationalPerson)",
"group_search_filter": "(objectClass=groupOfNames)",
}

def configure(self, config: Dict):
Expand Down Expand Up @@ -66,7 +70,7 @@ def fetch_users(self, refresh: bool = False) -> Dict[str, User]:

connection.search(
search_base=self.config["base_dn"],
search_filter="(objectclass=organizationalPerson)",
search_filter=self.config["search_filter"],
search_scope=ldap3.SUBTREE,
attributes=[
"description",
Expand Down Expand Up @@ -113,7 +117,7 @@ def fetch_groups(self):

connection.search(
search_base=self.config["base_dn"],
search_filter="(objectClass=groupOfNames)",
search_filter=self.config["group_search_filter"],
search_scope=ldap3.SUBTREE,
attributes=["description", "mail", "member", "cn"],
)
Expand Down

0 comments on commit 1d13021

Please sign in to comment.