Skip to content

Commit

Permalink
LDAP3: Allow the user to set the search filter.
Browse files Browse the repository at this point in the history
This should allow us to only sync a subset of users.

Closes: #98
  • Loading branch information
thinkl33t committed Dec 5, 2023
1 parent e0e655b commit 2a6056a
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 2a6056a

Please sign in to comment.