fix ldaps protocol (#6384)

fix: ldap default protocol (#2156)

Signed-off-by: peng wu <2030047311@qq.com>
This commit is contained in:
smartcat999
2025-03-03 16:03:40 +08:00
committed by GitHub
parent 430a3589d8
commit f77b0afd85

View File

@@ -13,6 +13,7 @@ import (
"net"
"net/url"
"os"
"strings"
"time"
"github.com/go-ldap/ldap"
@@ -165,7 +166,11 @@ func (l ldapProvider) Authenticate(username string, password string) (identitypr
}
func (l *ldapProvider) newConn() (*ldap.Conn, error) {
lurl, err := url.Parse(l.Host)
host := l.Host
if !strings.HasPrefix(l.Host, "ldap://") && !strings.HasPrefix(l.Host, "ldaps://") {
host = "ldap://" + l.Host
}
lurl, err := url.Parse(host)
if err != nil {
return nil, ldap.NewError(ldap.ErrorNetwork, err)
}