mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00
Fix active LDAP sync (#25321)
* LDAP: sync only users with 'ldap' module as a most recent auth module * LDAP: tests for searching ldap users
This commit is contained in:
@ -468,13 +468,7 @@ func SearchUsers(query *models.SearchUsersQuery) error {
|
||||
}
|
||||
|
||||
if query.AuthModule != "" {
|
||||
whereConditions = append(
|
||||
whereConditions,
|
||||
`u.id IN (SELECT user_id
|
||||
FROM user_auth
|
||||
WHERE auth_module=?)`,
|
||||
)
|
||||
|
||||
whereConditions = append(whereConditions, `auth_module=?`)
|
||||
whereParams = append(whereParams, query.AuthModule)
|
||||
}
|
||||
|
||||
@ -494,6 +488,11 @@ func SearchUsers(query *models.SearchUsersQuery) error {
|
||||
user := models.User{}
|
||||
countSess := x.Table("user").Alias("u")
|
||||
|
||||
// Join with user_auth table if users filtered by auth_module
|
||||
if query.AuthModule != "" {
|
||||
countSess.Join("LEFT", "user_auth", joinCondition)
|
||||
}
|
||||
|
||||
if len(whereConditions) > 0 {
|
||||
countSess.Where(strings.Join(whereConditions, " AND "), whereParams...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user