feat(minor): Add Custom Group Search for custom LDAP servers
This commit is contained in:
parent
7a9a95f10f
commit
c775ca1d1d
2 changed files with 15 additions and 1 deletions
|
|
@ -38,6 +38,7 @@
|
|||
"local_ca_certs_file",
|
||||
"ldap_custom_settings_section",
|
||||
"ldap_group_objectclass",
|
||||
"ldap_custom_group_search",
|
||||
"column_break_33",
|
||||
"ldap_group_member_attribute",
|
||||
"ldap_group_mappings_section",
|
||||
|
|
@ -247,6 +248,12 @@
|
|||
"fieldtype": "Data",
|
||||
"label": "Group Object Class"
|
||||
},
|
||||
{
|
||||
"description": "string value, i.e. {0} or uid={0},ou=users,dc=example,dc=com",
|
||||
"fieldname": "ldap_custom_group_search",
|
||||
"fieldtype": "Data",
|
||||
"label": "Custom Group Search"
|
||||
},
|
||||
{
|
||||
"description": "Requires any valid fdn path. i.e. ou=users,dc=example,dc=com",
|
||||
"fieldname": "ldap_search_path_user",
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ class LDAPSettings(Document):
|
|||
frappe.throw(_("Custom LDAP Directoy Selected, please ensure 'LDAP Group Member attribute' and 'Group Object Class' are entered"),
|
||||
title=_("Misconfigured"))
|
||||
|
||||
if self.ldap_custom_group_search and "{0}" not in self.ldap_custom_group_search:
|
||||
frappe.throw(_("Custom Group Search if filled needs to contain the user placeholder {0}, eg uid={0},ou=users,dc=example,dc=com"),
|
||||
title=_("Misconfigured"))
|
||||
|
||||
else:
|
||||
frappe.throw(_("LDAP Search String must be enclosed in '()' and needs to contian the user placeholder {0}, eg sAMAccountName={0}"))
|
||||
|
||||
|
|
@ -209,7 +213,10 @@ class LDAPSettings(Document):
|
|||
|
||||
ldap_object_class = self.ldap_group_objectclass
|
||||
ldap_group_members_attribute = self.ldap_group_member_attribute
|
||||
user_search_str = getattr(user, self.ldap_username_field).value
|
||||
ldap_custom_group_search = "{0}"
|
||||
if self.ldap_custom_group_search:
|
||||
ldap_custom_group_search = self.ldap_custom_group_search
|
||||
user_search_str = ldap_custom_group_search.format(getattr(user, self.ldap_username_field).value)
|
||||
|
||||
else:
|
||||
# NOTE: depreciate this else path
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue