Abort syncrhonization from LDAP source if there is some error. (#7960)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
This commit is contained in:
parent
e3115cc019
commit
8c24bb9e43
|
@ -1673,7 +1673,12 @@ func SyncExternalUsers() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sr := s.LDAP().SearchEntries()
|
sr, err := s.LDAP().SearchEntries()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("SyncExternalUsers LDAP source failure [%s], skipped", s.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for _, su := range sr {
|
for _, su := range sr {
|
||||||
if len(su.Username) == 0 {
|
if len(su.Username) == 0 {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -308,12 +308,12 @@ func (ls *Source) UsePagedSearch() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchEntries : search an LDAP source for all users matching userFilter
|
// SearchEntries : search an LDAP source for all users matching userFilter
|
||||||
func (ls *Source) SearchEntries() []*SearchResult {
|
func (ls *Source) SearchEntries() ([]*SearchResult, error) {
|
||||||
l, err := dial(ls)
|
l, err := dial(ls)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("LDAP Connect error, %s:%v", ls.Host, err)
|
log.Error("LDAP Connect error, %s:%v", ls.Host, err)
|
||||||
ls.Enabled = false
|
ls.Enabled = false
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
defer l.Close()
|
defer l.Close()
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ func (ls *Source) SearchEntries() []*SearchResult {
|
||||||
err := l.Bind(ls.BindDN, ls.BindPassword)
|
err := l.Bind(ls.BindDN, ls.BindPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to bind as BindDN[%s]: %v", ls.BindDN, err)
|
log.Debug("Failed to bind as BindDN[%s]: %v", ls.BindDN, err)
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Trace("Bound as BindDN %s", ls.BindDN)
|
log.Trace("Bound as BindDN %s", ls.BindDN)
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,7 +350,7 @@ func (ls *Source) SearchEntries() []*SearchResult {
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("LDAP Search failed unexpectedly! (%v)", err)
|
log.Error("LDAP Search failed unexpectedly! (%v)", err)
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]*SearchResult, len(sr.Entries))
|
result := make([]*SearchResult, len(sr.Entries))
|
||||||
|
@ -368,5 +368,5 @@ func (ls *Source) SearchEntries() []*SearchResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue