Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLDAP (RFC1798 UDP/Connectionless) support to DialURL #397

Merged
merged 2 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func (dc *DialContext) dial(u *url.URL) (net.Conn, error) {
}

switch u.Scheme {
case "cldap":
if port == "" {
port = DefaultLdapPort
}
return dc.d.Dial("udp", net.JoinHostPort(host, port))
case "ldap":
if port == "" {
port = DefaultLdapPort
Expand Down Expand Up @@ -203,7 +208,8 @@ func DialTLS(network, addr string, config *tls.Config) (*Conn, error) {
}

// DialURL connects to the given ldap URL.
// The following schemas are supported: ldap://, ldaps://, ldapi://.
// The following schemas are supported: ldap://, ldaps://, ldapi://,
// and cldap:// (RFC1798, deprecated but used by Active Directory).
// On success a new Conn for the connection is returned.
func DialURL(addr string, opts ...DialOpt) (*Conn, error) {
u, err := url.Parse(addr)
Expand Down
8 changes: 7 additions & 1 deletion v3/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func (dc *DialContext) dial(u *url.URL) (net.Conn, error) {
}

switch u.Scheme {
case "cldap":
if port == "" {
port = DefaultLdapPort
}
return dc.d.Dial("udp", net.JoinHostPort(host, port))
case "ldap":
if port == "" {
port = DefaultLdapPort
Expand Down Expand Up @@ -203,7 +208,8 @@ func DialTLS(network, addr string, config *tls.Config) (*Conn, error) {
}

// DialURL connects to the given ldap URL.
// The following schemas are supported: ldap://, ldaps://, ldapi://.
// The following schemas are supported: ldap://, ldaps://, ldapi://,
// and cldap:// (RFC1798, deprecated but used by Active Directory).
// On success a new Conn for the connection is returned.
func DialURL(addr string, opts ...DialOpt) (*Conn, error) {
u, err := url.Parse(addr)
Expand Down