From a345c2198c571b62fb4642f93d0cb789f1d2485b Mon Sep 17 00:00:00 2001 From: David Holder Date: Wed, 27 May 2015 11:10:52 -0700 Subject: [PATCH] Add IPv6 support to ADS client side LDAP connects. Corrected format for IPv6 LDAP URI. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=11281 (Back ported from commit c324d7901c991a6700abdc3ee701920fea5e5819) Signed-off-by: David Holder Reviewed-by: Jeremy Allison Reviewed-by: Ralph Böhme --- source3/libads/ldap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index b9adc9d..c1eecec 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -87,7 +87,13 @@ static void gotalarm_sig(int signum) #ifndef LDAP_PROTO_TCP #define LDAP_PROTO_TCP 1 #endif - uri = talloc_asprintf(talloc_tos(), "ldap://%s:%u", server, port); + if ( strchr_m(server, ':') ) { + /* IPv6 URI */ + uri = talloc_asprintf(talloc_tos(), "ldap://[%s]:%u", server, port); + } else { + /* IPv4 URI */ + uri = talloc_asprintf(talloc_tos(), "ldap://%s:%u", server, port); + } if (uri == NULL) { return NULL; } -- 2.2.0.rc0.207.ga3a616c