diff --git a/models/ldap.go b/models/ldap.go index cb88f0d..98c8bea 100644 --- a/models/ldap.go +++ b/models/ldap.go @@ -105,14 +105,14 @@ func VerifyLdapCreds(username string, password string) bool { InsecureSkipVerify: true, } - // try connecting to AD via TLS and our custom certificate authority // Add port if not specified in .env file - if strings.HasSuffix(ldapServer, ":636") { - ldaps, err = ldap.DialTLS("tcp", ldapServer, tlsConfig) - } else { - ldaps, err = ldap.DialTLS("tcp", fmt.Sprintf("%s:636", ldapServer), tlsConfig) + if !(strings.HasSuffix(ldapServer, ":636")) { + ldapServer = fmt.Sprintf("%s:636", ldapServer) + log.Printf("VerifyLdapCreds updated ldapServer string '%s'\n", ldapServer) } + // try connecting to AD via TLS and our custom certificate authority + ldaps, err = ldap.DialTLS("tcp", ldapServer, tlsConfig) if err != nil { log.Printf("VerifyLdapCreds error connecting to LDAP bind address '%s' : '%s'\n", ldapServer, err) return false