| 238 | } |
| 239 | |
| 240 | func (ldap *LdapService) heartbeat() error { |
| 241 | tlog.App.Debug().Msg("Performing LDAP connection heartbeat") |
| 242 | |
| 243 | searchRequest := ldapgo.NewSearchRequest( |
| 244 | "", |
| 245 | ldapgo.ScopeBaseObject, ldapgo.NeverDerefAliases, 0, 0, false, |
| 246 | "(objectClass=*)", |
| 247 | []string{}, |
| 248 | nil, |
| 249 | ) |
| 250 | |
| 251 | ldap.mutex.Lock() |
| 252 | defer ldap.mutex.Unlock() |
| 253 | _, err := ldap.conn.Search(searchRequest) |
| 254 | if err != nil { |
| 255 | return err |
| 256 | } |
| 257 | |
| 258 | // No error means the connection is alive |
| 259 | return nil |
| 260 | } |
| 261 | |
| 262 | func (ldap *LdapService) reconnect() error { |
| 263 | tlog.App.Info().Msg("Reconnecting to LDAP server") |