Skip to content

Commit f9dd354

Browse files
committed
Reconnect fix
1 parent c7be868 commit f9dd354

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,18 @@ func main() {
401401
)
402402
response, err := conn.Search(request)
403403
if err != nil {
404-
if v, ok := err.(*ldap.Error); ok && v.ResultCode == 201 {
404+
if v, ok := err.(*ldap.Error); ok {
405+
if v.ResultCode == 201 {
406+
continue
407+
} else if v.ResultCode == 200 {
408+
// network error
409+
log.Print("lost LDAP connection, reconnecting\n")
410+
conn.Close()
411+
continue reconnectLoop
412+
}
413+
log.Printf("failed to execute search request: %v\n", err)
405414
continue
406415
}
407-
log.Printf("failed to execute search request: %v", err)
408-
continue
409416
}
410417

411418
// Did we catch something?

0 commit comments

Comments
 (0)