From 810df4e27898901fcda075e5da95e0af108e3504 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Mon, 10 Oct 2022 08:23:47 +0100 Subject: [PATCH 1/2] Add CLDAP (RFC1798 UDP/Connectionless) support to DialURL This is actually a deprecated RFC, however Active Directory relies on it for server discovery. Without this patch CLDAP is possible via directt use of the the deprecated `Dial` function with a UDP network connection. This patch adds the same support to the DialURL function. --- v3/conn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/v3/conn.go b/v3/conn.go index 25a691cb..170f4af8 100644 --- a/v3/conn.go +++ b/v3/conn.go @@ -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 @@ -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) From 2b26c8b3d23883bd75cc95c75984b87a640657fc Mon Sep 17 00:00:00 2001 From: Christopher Puschmann Date: Fri, 14 Oct 2022 23:25:10 +0200 Subject: [PATCH 2/2] Mirror code changes to root folder --- conn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conn.go b/conn.go index 25a691cb..170f4af8 100644 --- a/conn.go +++ b/conn.go @@ -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 @@ -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)