Debug( LDAP_DEBUG_TRACE, "ldap_int_open_connection\n", 0, 0, 0 );
- port = srv->lud_port;
- if (port == 0)
- port = ld->ld_options.ldo_defport;
- port = htons( (short) port );
-
- addr = 0;
- if ( srv->lud_host == NULL || *srv->lud_host == 0 )
- addr = htonl( INADDR_LOOPBACK );
-
switch ( ldap_pvt_url_scheme2proto( srv->lud_scheme ) ) {
case LDAP_PROTO_TCP:
+ port = htons( (short) srv->lud_port );
+
+ addr = 0;
+ if ( srv->lud_host == NULL || *srv->lud_host == 0 )
+ addr = htonl( INADDR_LOOPBACK );
+
rc = ldap_connect_to_host( ld, conn->lconn_sb, 0,
srv->lud_host, addr, port, async );
+
if ( rc == -1 ) return rc;
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_tcp,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
int rc = LDAP_OPT_SUCCESS;
if(host != NULL) {
- rc = ldap_url_parsehosts(&ludlist, host);
+ rc = ldap_url_parsehosts( &ludlist, host,
+ lo->ldo_defport ? lo->ldo_defport : LDAP_PORT );
} else if(ld == NULL) {
/*
ludp->lud_next = NULL;
ludp->lud_host = NULL;
- ludp->lud_port = 0;
+ ludp->lud_port = LDAP_PORT;
ludp->lud_dn = NULL;
ludp->lud_attrs = NULL;
ludp->lud_filter = NULL;
return LDAP_URL_ERR_MEM;
}
+ if( strcasecmp( ludp->lud_scheme, "ldaps" ) == 0 ) {
+ ludp->lud_port = LDAPS_PORT;
+ }
+
/* scan forward for '/' that marks end of hostport and begin. of dn */
p = strchr( url, '/' );
}
int
-ldap_url_parsehosts (LDAPURLDesc **ludlist, const char *hosts )
+ldap_url_parsehosts(
+ LDAPURLDesc **ludlist,
+ const char *hosts,
+ int port )
{
int i;
LDAPURLDesc *ludp;
*ludlist = NULL;
return LDAP_NO_MEMORY;
}
+ ludp->lud_port = port;
ludp->lud_host = specs[i];
specs[i] = NULL;
p = strchr(ludp->lud_host, ':');