]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/search.c
Add #include <openssl/safestack.h> to fix ITS#1412
[openldap] / libraries / libldap / search.c
index 2d2071030261cf7545a8e2f6dfd624717a169639..50f50067ff92dfe2d6d32fcd46f9226367758429 100644 (file)
@@ -91,6 +91,7 @@ ldap_search_ext(
        int sizelimit,
        int *msgidp )
 {
+       int rc;
        BerElement      *ber;
        int timelimit;
 
@@ -99,6 +100,10 @@ ldap_search_ext(
        assert( ld != NULL );
        assert( LDAP_VALID( ld ) );
 
+       /* check client controls */
+       rc = ldap_int_client_controls( ld, cctrls );
+       if( rc != LDAP_SUCCESS ) return rc;
+
        /*
         * if timeout is provided, both tv_sec and tv_usec must
         * be non-zero
@@ -292,11 +297,28 @@ ldap_build_search_req(
                }
        }
 
-       err = ber_printf( ber, "{it{seeiib", ++ld->ld_msgid,
+#ifdef LDAP_CONNECTIONLESS
+       if ( LDAP_IS_UDP(ld) ) {
+           err = ber_write( ber, ld->ld_options.ldo_peer,
+                   sizeof(struct sockaddr), 0);
+       }
+       if ( LDAP_IS_UDP(ld) && ld->ld_options.ldo_version == LDAP_VERSION2) {
+           char *dn = ld->ld_options.ldo_cldapdn;
+           if (!dn) dn = "";
+           err = ber_printf( ber, "{ist{seeiib", ++ld->ld_msgid, dn,
+               LDAP_REQ_SEARCH, base, (ber_int_t) scope, ld->ld_deref,
+               (sizelimit < 0) ? ld->ld_sizelimit : sizelimit,
+               (timelimit < 0) ? ld->ld_timelimit : timelimit,
+               attrsonly );
+       } else
+#endif
+       {
+           err = ber_printf( ber, "{it{seeiib", ++ld->ld_msgid,
                LDAP_REQ_SEARCH, base, (ber_int_t) scope, ld->ld_deref,
                (sizelimit < 0) ? ld->ld_sizelimit : sizelimit,
                (timelimit < 0) ? ld->ld_timelimit : timelimit,
                attrsonly );
+       }
 
        if ( err == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;