Skip to content

Commit

Permalink
Fix unauth bind issues due to lib update (hashicorp#3293)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishoffman authored Sep 7, 2017
1 parent 4f3dfb2 commit 6f5619b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions builtin/credential/ldap/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ func (b *backend) Login(req *logical.Request, username string, password string)
}

// Try to bind as the login user. This is where the actual authentication takes place.
if err = c.Bind(userBindDN, password); err != nil {
if len(password) > 0 {
err = c.Bind(userBindDN, password)
} else {
err = c.UnauthenticatedBind(userBindDN)
}
if err != nil {
return nil, logical.ErrorResponse(fmt.Sprintf("LDAP bind failed: %v", err)), nil
}

Expand Down Expand Up @@ -237,7 +242,13 @@ func (b *backend) getCN(dn string) string {
func (b *backend) getUserBindDN(cfg *ConfigEntry, c *ldap.Conn, username string) (string, error) {
bindDN := ""
if cfg.DiscoverDN || (cfg.BindDN != "" && cfg.BindPassword != "") {
if err := c.Bind(cfg.BindDN, cfg.BindPassword); err != nil {
var err error
if cfg.BindPassword != "" {
err = c.Bind(cfg.BindDN, cfg.BindPassword)
} else {
err = c.UnauthenticatedBind(cfg.BindDN)
}
if err != nil {
return bindDN, fmt.Errorf("LDAP bind (service) failed: %v", err)
}

Expand Down

0 comments on commit 6f5619b

Please sign in to comment.