Skip to content

Commit

Permalink
Merge pull request #55 from wiltonsr/strip-commas
Browse files Browse the repository at this point in the history
Strip comma when baseDN is empty
  • Loading branch information
wiltonsr authored Nov 23, 2023
2 parents 6d73d8b + 2d44c49 commit 66002e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ldapauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"crypto/x509"
"errors"
"fmt"
"text/template"
"io/ioutil"
"log"
"net"
Expand All @@ -19,6 +18,7 @@ import (
"reflect"
"strconv"
"strings"
"text/template"

"github.com/go-ldap/ldap/v3"
"github.com/gorilla/sessions"
Expand Down Expand Up @@ -241,6 +241,7 @@ func LdapCheckUser(conn *ldap.Conn, config *Config, username, password string) (
if config.SearchFilter == "" {
LoggerDEBUG.Printf("Running in Bind Mode")
userDN := fmt.Sprintf("%s=%s,%s", config.Attribute, username, config.BaseDN)
userDN = strings.Trim(userDN, ",")
LoggerDEBUG.Printf("Authenticating User: %s", userDN)
err := conn.Bind(userDN, password)
return err == nil, ldap.NewEntry(userDN, nil), err
Expand Down

0 comments on commit 66002e5

Please sign in to comment.