}
int
-ldap_start_tls ( LDAP *ld )
+ldap_start_tls ( LDAP *ld,
+ LDAPControl **serverctrls,
+ LDAPControl **clientctrls )
{
+#ifdef HAVE_TLS
LDAPConn *lc;
int rc;
- char *rspoid;
- struct berval *rspdata;
+ char *rspoid = NULL;
+ struct berval *rspdata = NULL;
if (ld->ld_conns == NULL) {
rc = ldap_open_defconn( ld );
if (ldap_pvt_tls_inplace(lc->lconn_sb) != 0)
return LDAP_OPERATIONS_ERROR;
rc = ldap_extended_operation_s(ld, LDAP_EXOP_START_TLS,
- NULL, NULL, NULL, &rspoid, &rspdata);
+ NULL, serverctrls, clientctrls, &rspoid, &rspdata);
if (rc != LDAP_SUCCESS)
return rc;
+ if (rspoid != NULL)
+ LDAP_FREE(rspoid);
+ if (rspdata != NULL)
+ ber_bvfree(rspdata);
rc = ldap_pvt_tls_start( lc->lconn_sb, ld->ld_options.ldo_tls_ctx );
if (rc != LDAP_SUCCESS)
return rc;
}
return LDAP_SUCCESS;
+#else
+ return LDAP_NOT_SUPPORTED;
+#endif
}
int
char **krbinstancep, int async )
{
int rc = -1;
- int port, tls;
+ int port;
+#ifdef HAVE_TLS
+ int tls;
+#endif
long addr;
Debug( LDAP_DEBUG_TRACE, "open_ldap_connection\n", 0, 0, 0 );
port = htons( (short) port );
addr = 0;
- if ( srv->lud_host == NULL )
+ if ( srv->lud_host == NULL || *srv->lud_host == 0 )
addr = htonl( INADDR_LOOPBACK );
- rc = ldap_connect_to_host( ld, sb, srv->lud_host, addr, port, async );
+ switch ( srv->lud_protocol ) {
+ case LDAP_PROTO_TCP:
+ case LDAP_PROTO_UDP:
+ rc = ldap_connect_to_host( ld, sb, srv->lud_host, addr, port, async );
+ break;
+#ifdef LDAP_PF_LOCAL
+ case LDAP_PROTO_LOCAL:
+ rc = ldap_connect_to_path( ld, sb, srv->lud_host, async );
+ break;
+#endif /* LDAP_PF_LOCAL */
+ default:
+ rc = -1;
+ break;
+ }
+
if ( rc == -1 ) {
return( rc );
}
ber_pvt_sb_set_io( sb, &ber_pvt_sb_io_tcp, NULL );
#ifdef HAVE_TLS
- tls = srv->lud_ldaps;
- if (tls == -1)
- tls = ld->ld_options.ldo_tls_mode;
- if ( tls != 0 ) {
- rc = ldap_pvt_tls_start( sb, ld->ld_options.ldo_tls_ctx );
- if (rc != LDAP_SUCCESS)
- return rc;
+ tls = (srv->lud_properties & LDAP_URL_USE_SSL);
+ if (tls == 0)
+ tls = (srv->lud_properties & LDAP_URL_USE_SSL_UNSPECIFIED);
+
+ if ( tls != 0 ) {
+ rc = ldap_pvt_tls_start( sb, ld->ld_options.ldo_tls_ctx );
+ if (rc != LDAP_SUCCESS)
+ return rc;
}
#endif
+
if ( krbinstancep != NULL ) {
#ifdef HAVE_KERBEROS
char *c;