From c5014a7f2c4a263818269216d16d6f21b008cd17 Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 20 Jan 2020 03:47:39 +0000 Subject: Add option to prevent LDAP from deactivating everything on empty search (#9879) * Add option to prevent LDAP from deactivating everything on empty search * Update options/locale/locale_en-US.ini Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lunny Xiao --- models/user.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'models/user.go') diff --git a/models/user.go b/models/user.go index 4a4af3547a..c2631d5dd2 100644 --- a/models/user.go +++ b/models/user.go @@ -1780,6 +1780,15 @@ func SyncExternalUsers(ctx context.Context) { continue } + if len(sr) == 0 { + if !s.LDAP().AllowDeactivateAll { + log.Error("LDAP search found no entries but did not report an error. Refusing to deactivate all users") + continue + } else { + log.Warn("LDAP search found no entries but did not report an error. All users will be deactivated as per settings") + } + } + for _, su := range sr { select { case <-ctx.Done(): -- cgit v1.2.3