From ff559f551a23a5001ef0790b97652377a8b5fcab Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Mon, 30 Nov 1998 03:55:49 +0000
Subject: [PATCH] Remove LDAP_PORT dependencies so that ldap.conf defaults take
 over.

---
 clients/fax500/rp500.c      | 2 +-
 clients/gopher/go500.c      | 2 +-
 clients/mail500/main.c      | 2 +-
 clients/tools/ldapmodify.c  | 2 +-
 clients/ud/main.c           | 2 +-
 libraries/libldap/request.c | 4 ++--
 libraries/libldap/url.c     | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c
index 67de48322d..8f81e70afb 100644
--- a/clients/fax500/rp500.c
+++ b/clients/fax500/rp500.c
@@ -110,7 +110,7 @@ main( int argc, char **argv )
 		exit( -1 );
 	}
 
-	if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+	if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
 		perror( "ldap_open" );
 		exit( -1 );
 	}
diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c
index de0059380a..ca582e939b 100644
--- a/clients/gopher/go500.c
+++ b/clients/gopher/go500.c
@@ -378,7 +378,7 @@ do_queries( int s )
 
 	if ( *query == '~' || *query == '@' ) {
 		ld = NULL;
-	} else if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+	} else if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
 		fprintf(fp,
 			"0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
 			LDAP_SERVER_DOWN, myhost, myport );
diff --git a/clients/mail500/main.c b/clients/mail500/main.c
index f405bd31bb..b147908db6 100644
--- a/clients/mail500/main.c
+++ b/clients/mail500/main.c
@@ -355,7 +355,7 @@ connect_to_x500( void )
 {
 	int opt;
 
-	if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+	if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
 		syslog( LOG_ALERT, "ldap_open failed" );
 		return( -1 );
 	}
diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c
index f30815a706..88756ada24 100644
--- a/clients/tools/ldapmodify.c
+++ b/clients/tools/ldapmodify.c
@@ -262,7 +262,7 @@ process_ldif_rec( char *rbuf )
 	    if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) {
 		++saw_replica;
 		if (( p = strchr( value, ':' )) == NULL ) {
-		    replicaport = LDAP_PORT;
+		    replicaport = 0;
 		} else {
 		    *p++ = '\0';
 		    replicaport = atoi( p );
diff --git a/clients/ud/main.c b/clients/ud/main.c
index 5a527c2979..79fab94ff0 100644
--- a/clients/ud/main.c
+++ b/clients/ud/main.c
@@ -59,7 +59,7 @@ char copyright[] =
 static char *server = NULL;
 static char *config_file = UD_CONFIG_FILE;
 static char *filter_file = FILTERFILE;
-static int ldap_port = LDAP_PORT;
+static int ldap_port = 0;
 static int dereference = TRUE;
 
 char *default_bind_object = NULL;
diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c
index 821a29aa74..f2d290e876 100644
--- a/libraries/libldap/request.c
+++ b/libraries/libldap/request.c
@@ -696,7 +696,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
 				*ports++ = '\0';
 				srv->lsrv_port = atoi( ports );
 			} else {
-				srv->lsrv_port = LDAP_PORT;
+				srv->lsrv_port = openldap_ldap_global_options.ldo_defport;
 			}
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
 		} else {
@@ -879,7 +879,7 @@ dn2servers( LDAP *ld, char *dn )	/* dn can also be a domain.... */
 	srvlist = NULL;
 
 	for ( i = 0; dxs[ i ] != NULL; ++i ) {
-		port = LDAP_PORT;
+		port = openldap_ldap_global_options.ldo_defport;
 		server_dn = NULL;
 		if ( strchr( dxs[ i ], ':' ) == NULL ) {
 			host = dxs[ i ];
diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c
index bc6726164f..510d89ac1a 100644
--- a/libraries/libldap/url.c
+++ b/libraries/libldap/url.c
@@ -272,7 +272,7 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
 			err = -1;
 		} else {
 			if ( ludp->lud_port == 0 ) {
-				srv->lsrv_port = LDAP_PORT;
+				srv->lsrv_port = openldap_ldap_global_options.ldo_defport;
 			} else {
 				 srv->lsrv_port = ludp->lud_port;
 			}
-- 
GitLab