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
Branches
No related tags found
No related merge requests found
...@@ -40,10 +40,12 @@ func (p *ConnectionPool) connect(ctx context.Context) (*ldap.Conn, error) { ...@@ -40,10 +40,12 @@ func (p *ConnectionPool) connect(ctx context.Context) (*ldap.Conn, error) {
conn := ldap.NewConn(c, false) conn := ldap.NewConn(c, false)
conn.Start() conn.Start()
conn.SetTimeout(time.Until(deadline)) if p.bindDN != "" {
if _, err = conn.SimpleBind(ldap.NewSimpleBindRequest(p.bindDN, p.bindPw, nil)); err != nil { conn.SetTimeout(time.Until(deadline))
conn.Close() if _, err = conn.SimpleBind(ldap.NewSimpleBindRequest(p.bindDN, p.bindPw, nil)); err != nil {
return nil, err conn.Close()
return nil, err
}
} }
return conn, 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