]> git.sur5r.net Git - openldap/blobdiff - tests/progs/slapd-bind.c
Happy New Year
[openldap] / tests / progs / slapd-bind.c
index 541a473644b4c9a9b8c8dd897c2b376c0a1a06d3..4575aa123d9fa36aad0e994fe337e2b83266dd0a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2017 The OpenLDAP Foundation.
+ * Copyright 1999-2018 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
 
 #include "ldap.h"
 #include "lutil.h"
+#include "lutil_ldap.h"
 #include "lber_pvt.h"
 #include "ldap_pvt.h"
 
@@ -201,6 +202,7 @@ do_bind( struct tester_conn_args *config, char *dn, int maxloop,
        int force, int noinit, LDAP **ldp, int action_type, void *action )
 {
        LDAP    *ld = ldp ? *ldp : NULL;
+       char    *bindfunc = "ldap_sasl_bind_s";
        int     i, rc = -1;
 
        /* for internal search */
@@ -257,9 +259,41 @@ do_bind( struct tester_conn_args *config, char *dn, int maxloop,
        for ( i = 0; i < maxloop; i++ ) {
                if ( !noinit || ld == NULL ) {
                        tester_init_ld( &ld, config, TESTER_INIT_ONLY );
+
+#ifdef HAVE_CYRUS_SASL
+                       if ( config->secprops != NULL ) {
+                               rc = ldap_set_option( ld,
+                                               LDAP_OPT_X_SASL_SECPROPS, config->secprops );
+
+                               if( rc != LDAP_OPT_SUCCESS ) {
+                                       tester_ldap_error( ld, "ldap_set_option(SECPROPS)", NULL );
+                                       exit( EXIT_FAILURE );
+                               }
+                       }
+#endif
+               }
+
+               if ( config->authmethod == LDAP_AUTH_SASL ) {
+#ifdef HAVE_CYRUS_SASL
+                       bindfunc = "ldap_sasl_interactive_bind_s";
+                       rc = ldap_sasl_interactive_bind_s( ld,
+                                       config->binddn,
+                                       config->mech,
+                                       NULL, NULL,
+                                       LDAP_SASL_QUIET,
+                                       lutil_sasl_interact,
+                                       config->defaults );
+#else /* HAVE_CYRUS_SASL */
+                       /* caller shouldn't have allowed this */
+                       assert(0);
+#endif
+               } else if ( config->authmethod == LDAP_AUTH_SIMPLE ) {
+                       bindfunc = "ldap_sasl_bind_s";
+                       rc = ldap_sasl_bind_s( ld,
+                                       config->binddn, LDAP_SASL_SIMPLE,
+                                       &config->pass, NULL, NULL, NULL );
                }
 
-               rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &config->pass, NULL, NULL, NULL );
                if ( rc ) {
                        int first = tester_ignore_err( rc );
 
@@ -267,12 +301,12 @@ do_bind( struct tester_conn_args *config, char *dn, int maxloop,
                        if ( first ) {
                                /* only log if first occurrence */
                                if ( ( force < 2 && first > 0 ) || abs(first) == 1 ) {
-                                       tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
+                                       tester_ldap_error( ld, bindfunc, NULL );
                                }
                                rc = LDAP_SUCCESS;
 
                        } else {
-                               tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
+                               tester_ldap_error( ld, bindfunc, NULL );
                        }
                }
 
@@ -459,10 +493,6 @@ novals:;
                {
                        break;
                }
-
-               if ( config->delay ) {
-                       sleep( config->delay );
-               }
        }
 
        if ( ld != NULL ) {