Skip to content
Snippets Groups Projects
Commit 31066b08 authored by ale's avatar ale
Browse files

Support anonymous LDAP connections

Simply by setting an empty bind DN.
parent 7eb77848
No related branches found
No related tags found
No related merge requests found
......@@ -40,10 +40,12 @@ func (p *ConnectionPool) connect(ctx context.Context) (*ldap.Conn, error) {
conn := ldap.NewConn(c, false)
conn.Start()
conn.SetTimeout(time.Until(deadline))
if _, err = conn.SimpleBind(ldap.NewSimpleBindRequest(p.bindDN, p.bindPw, nil)); err != nil {
conn.Close()
return nil, err
if p.bindDN != "" {
conn.SetTimeout(time.Until(deadline))
if _, err = conn.SimpleBind(ldap.NewSimpleBindRequest(p.bindDN, p.bindPw, nil)); err != nil {
conn.Close()
return nil, err
}
}
return conn, err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment