/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
}
Debug( LDAP_DEBUG_TRACE, "ldap_open: %s\n",
- ld == NULL ? "succeeded" : "failed", 0, 0 );
+ ld != NULL ? "succeeded" : "failed", 0, 0 );
return ld;
}
ld->ld_options.ldo_sctrls = NULL;
ld->ld_options.ldo_cctrls = NULL;
ld->ld_options.ldo_defludp = NULL;
+ ld->ld_options.ldo_conn_cbs = NULL;
#ifdef HAVE_CYRUS_SASL
ld->ld_options.ldo_def_sasl_mech = gopts->ldo_def_sasl_mech
ldap_unbind_ext( ld, NULL, NULL );
return( LDAP_NO_MEMORY );
}
+ if( url )
+ conn->lconn_server = ldap_url_dup( ld->ld_options.ldo_defludp );
ber_sockbuf_ctrl( conn->lconn_sb, LBER_SB_OPT_SET_FD, &fd );
ld->ld_defconn = conn;
++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */
int async )
{
int rc = -1;
- char *host;
- int port, proto;
+ int proto;
Debug( LDAP_DEBUG_TRACE, "ldap_int_open_connection\n", 0, 0, 0 );
switch ( proto = ldap_pvt_url_scheme2proto( srv->lud_scheme ) ) {
case LDAP_PROTO_TCP:
- port = srv->lud_port;
-
- if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
- host = NULL;
- } else {
- host = srv->lud_host;
- }
-
- if( !port ) {
- if( strcmp(srv->lud_scheme, "ldaps") == 0 ) {
- port = LDAPS_PORT;
- } else {
- port = LDAP_PORT;
- }
- }
-
rc = ldap_connect_to_host( ld, conn->lconn_sb,
- proto, host, port, async );
+ proto, srv, async );
if ( rc == -1 ) return rc;
-
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_PROVIDER, (void *)"tcp_" );
#ifdef LDAP_CONNECTIONLESS
case LDAP_PROTO_UDP:
- port = srv->lud_port;
-
- if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
- host = NULL;
- } else {
- host = srv->lud_host;
- }
-
- if( !port ) port = LDAP_PORT;
-
LDAP_IS_UDP(ld) = 1;
rc = ldap_connect_to_host( ld, conn->lconn_sb,
- proto, host, port, async );
+ proto, srv, async );
if ( rc == -1 ) return rc;
#ifdef LDAP_DEBUG
#ifdef LDAP_PF_LOCAL
/* only IPC mechanism supported is PF_LOCAL (PF_UNIX) */
rc = ldap_connect_to_path( ld, conn->lconn_sb,
- srv->lud_host, async );
+ srv, async );
if ( rc == -1 ) return rc;
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,