From fcd2fbcfe75f337c8a104de54214796bdd1f86b8 Mon Sep 17 00:00:00 2001 From: stonezdj Date: Tue, 29 Jun 2021 20:20:47 +0800 Subject: [PATCH] Add ldap_group_dn parameter to search group with ldap group dn Fixes #15171 Cannot use q.Query because ldap_group_dn contains comma(,) and equal(=), which are reserved characters in q.Query Signed-off-by: stonezdj --- api/v2.0/swagger.yaml | 5 +++++ src/server/v2.0/handler/usergroup.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/api/v2.0/swagger.yaml b/api/v2.0/swagger.yaml index 6e0482b04..6f7ba8565 100644 --- a/api/v2.0/swagger.yaml +++ b/api/v2.0/swagger.yaml @@ -2697,6 +2697,11 @@ paths: - usergroup parameters: - $ref: '#/parameters/requestId' + - name: ldap_group_dn + in: query + type: string + required: false + description: search with ldap group DN responses: '200': description: Get user group successfully. diff --git a/src/server/v2.0/handler/usergroup.go b/src/server/v2.0/handler/usergroup.go index 34e61e0b7..7e3fc8dab 100644 --- a/src/server/v2.0/handler/usergroup.go +++ b/src/server/v2.0/handler/usergroup.go @@ -109,6 +109,9 @@ func (u *userGroupAPI) ListUserGroups(ctx context.Context, params operation.List switch authMode { case common.LDAPAuth: query.GroupType = common.LDAPGroupType + if params.LdapGroupDn != nil && len(*params.LdapGroupDn) > 0 { + query.LdapGroupDN = *params.LdapGroupDn + } case common.HTTPAuth: query.GroupType = common.HTTPGroupType }