[PATCH] smbldap: allow alternative port definitions

Björn Jacke bj at sernet.de
Thu Dec 7 15:29:13 UTC 2017


From: Bjoern Jacke <bjacke at samba.org>

on ldap libraries without ldap_initialize() it was not possible to define an
alternative connection port.

Signed-off-by: Bjoern Jacke <bjacke at samba.org>
---
 source3/lib/smbldap.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index ebefd04..e6fc42e 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -682,14 +682,16 @@ static int smb_ldap_setup_conn(LDAP **ldap_struct, const char *uri)
 
 		sscanf(uri, "%10[^:]://%254[^:/]:%d", protocol, host, &port);
 
-		if (port == 0) {
-			if (strequal(protocol, "ldap")) {
+		if (strequal(protocol, "ldap")) {
+			if (port == 0) {
 				port = LDAP_PORT;
-			} else if (strequal(protocol, "ldaps")) {
+			}
+		} else if (strequal(protocol, "ldaps")) {
+			if (port == 0) {
 				port = LDAPS_PORT;
-			} else {
-				DEBUG(0, ("unrecognised protocol (%s)!\n", protocol));
 			}
+		} else {
+			DEBUG(0, ("unrecognised protocol (%s)!\n", protocol));
 		}
 
 		if ((*ldap_struct = ldap_init(host, port)) == NULL)	{
-- 
2.7.4




More information about the samba-technical mailing list