PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel slapd-modrdn \
slapd-modify slapd-bind
-SRCS = slapd-tester.c slapd-search.c slapd-read.c slapd-addel.c \
+SRCS = slapd-common.c \
+ slapd-tester.c slapd-search.c slapd-read.c slapd-addel.c \
slapd-modrdn.c slapd-modify.c slapd-bind.c
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
XLIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) $(LDAP_LIBLUTIL_A)
-XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
+XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
+
+OBJS = slapd-common.o
# build-tools: FORCE
# $(MAKE) $(MFLAGS) load-tools
# load-tools: $(PROGRAMS)
-slapd-tester: slapd-tester.o $(XLIBS)
- $(LTLINK) -o $@ slapd-tester.o $(LIBS)
+slapd-tester: slapd-tester.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-tester.o $(OBJS) $(LIBS)
+
+slapd-search: slapd-search.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-search.o $(OBJS) $(LIBS)
-slapd-search: slapd-search.o $(XLIBS)
- $(LTLINK) -o $@ slapd-search.o $(LIBS)
+slapd-read: slapd-read.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-read.o $(OBJS) $(LIBS)
-slapd-read: slapd-read.o $(XLIBS)
- $(LTLINK) -o $@ slapd-read.o $(LIBS)
+slapd-addel: slapd-addel.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-addel.o $(OBJS) $(LIBS)
-slapd-addel: slapd-addel.o $(XLIBS)
- $(LTLINK) -o $@ slapd-addel.o $(LIBS)
+slapd-modrdn: slapd-modrdn.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-modrdn.o $(OBJS) $(LIBS)
-slapd-modrdn: slapd-modrdn.o $(XLIBS)
- $(LTLINK) -o $@ slapd-modrdn.o $(LIBS)
+slapd-modify: slapd-modify.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-modify.o $(OBJS) $(LIBS)
-slapd-modify: slapd-modify.o $(XLIBS)
- $(LTLINK) -o $@ slapd-modify.o $(LIBS)
+slapd-bind: slapd-bind.o $(OBJS) $(XLIBS)
+ $(LTLINK) -o $@ slapd-bind.o $(OBJS) $(LIBS)
-slapd-bind: slapd-bind.o $(XLIBS)
- $(LTLINK) -o $@ slapd-bind.o $(LIBS)
#include <ac/unistd.h>
#include <ac/wait.h>
-#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <lutil.h>
+#include "slapd-common.h"
+
#define LOOPS 100
#define RETRIES 0
get_add_entry( char *filename, LDAPMod ***mods );
static void
-do_addel( char *uri, char *host, int port, char *manager, char *passwd,
+do_addel( char *uri, char *manager, struct berval *passwd,
char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay,
int friendly );
char *uri = NULL;
int port = -1;
char *manager = NULL;
- char *passwd = NULL;
+ struct berval passwd = { 0, NULL };
char *filename = NULL;
char *entry = NULL;
int loops = LOOPS;
int friendly = 0;
LDAPMod **attrs = NULL;
+ tester_init( "slapd-modify" );
+
while ( (i = getopt( argc, argv, "FH:h:p:D:w:f:l:r:t:" )) != EOF ) {
switch( i ) {
case 'F':
break;
case 'w': /* the server managers password */
- passwd = strdup( optarg );
+ passwd.bv_val = strdup( optarg );
+ passwd.bv_len = strlen( optarg );
break;
case 'f': /* file with entry search request */
}
if (( filename == NULL ) || ( port == -1 && uri == NULL ) ||
- ( manager == NULL ) || ( passwd == NULL ))
+ ( manager == NULL ) || ( passwd.bv_val == NULL ))
usage( argv[0] );
entry = get_add_entry( filename, &attrs );
}
- do_addel( uri, host, port, manager, passwd, entry, attrs,
+ uri = tester_uri( uri, host, port );
+
+ do_addel( uri, manager, &passwd, entry, attrs,
loops, retries, delay, friendly );
exit( EXIT_SUCCESS );
if ( pmods == NULL || pmods[ i ] == NULL ) {
if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
sizeof( LDAPMod * ))) == NULL ) {
- perror( "realloc" );
+ tester_perror( "realloc" );
exit( EXIT_FAILURE );
}
*pmodsp = pmods;
pmods[ i + 1 ] = NULL;
if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
== NULL ) {
- perror( "calloc" );
+ tester_perror( "calloc" );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_op = modop;
if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
- perror( "strdup" );
+ tester_perror( "strdup" );
exit( EXIT_FAILURE );
}
}
if (( pmods[ i ]->mod_bvalues =
(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
(j + 2) * sizeof( struct berval * ))) == NULL ) {
- perror( "ber_realloc" );
+ tester_perror( "ber_memrealloc" );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
== NULL ) {
- perror( "malloc" );
+ tester_perror( "ber_memalloc" );
exit( EXIT_FAILURE );
}
pmods[ i ]->mod_bvalues[ j ] = bvp;
bvp->bv_len = vlen;
if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
- perror( "malloc" );
+ tester_perror( "malloc" );
exit( EXIT_FAILURE );
}
AC_MEMCPY( bvp->bv_val, value, vlen );
static void
do_addel(
char *uri,
- char *host,
- int port,
char *manager,
- char *passwd,
+ struct berval *passwd,
char *entry,
LDAPMod **attrs,
int maxloop,
int i = 0, do_retry = maxretries;
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
+ int version = LDAP_VERSION3;
retry:;
- if ( uri ) {
- ldap_initialize( &ld, uri );
- } else {
- ld = ldap_init( host, port );
- }
+ ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_init" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
- {
- int version = LDAP_VERSION3;
- (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
- &version );
- }
+ (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
- rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
+ rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
for ( ; i < maxloop; i++ ) {
/* add the entry */
- rc = ldap_add_s( ld, entry, attrs );
+ rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_add" );
+ tester_ldap_error( ld, "ldap_add_ext_s" );
switch ( rc ) {
case LDAP_ALREADY_EXISTS:
/* NOTE: this likely means
#endif
/* now delete the entry again */
- rc = ldap_delete_s( ld, entry );
+ rc = ldap_delete_ext_s( ld, entry, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_delete" );
+ tester_ldap_error( ld, "ldap_delete_ext_s" );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
done:;
fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc );
- ldap_unbind( ld );
+ ldap_unbind_ext( ld, NULL, NULL );
}
#include <ldap.h>
#include <lutil.h>
-#define LOOPS 100
-
-static void
-do_error( LDAP *ld, const char *func )
-{
- int err;
- const char *text = "Success";
-
- ldap_get_option( ld, LDAP_OPT_RESULT_CODE, (void *)&err );
- if ( err != LDAP_SUCCESS ) {
- ldap_get_option( ld, LDAP_OPT_ERROR_STRING, (void *)&text );
- }
+#include "slapd-common.h"
- fprintf( stderr, "%s: (%d) %s\n", func, err, text == NULL ? "" : text );
-}
+#define LOOPS 100
static int
do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force );
main( int argc, char **argv )
{
int i;
- char *uri = NULL,
- uribuf[ BUFSIZ ];
+ char *uri = NULL;
char *host = "localhost";
char *dn = NULL;
char *base = NULL;
int loops = LOOPS;
int force = 0;
+ tester_init( "slapd-bind" );
+
while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:f:F" )) != EOF ) {
switch( i ) {
case 'b': /* base DN of a tree of user DNs */
usage( argv[0] );
}
- if ( uri == NULL ) {
- snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", host, port );
- uri = uribuf;
- }
+ uri = tester_uri( uri, host, port );
if ( base ) {
do_base( uri, base, &pass, ( 20 * loops ), force );
for ( i = 0; i < maxloop; i++ ) {
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize" );
rc = -1;
break;
}
rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- do_error( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
}
ldap_unbind_ext( ld, NULL, NULL );
if ( rc != LDAP_SUCCESS && !force ) {
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_initialize" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
rc = ldap_sasl_bind_s( ld, NULL, LDAP_SASL_SIMPLE, NULL, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- do_error( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
exit( EXIT_FAILURE );
}
rc = ldap_search_ext( ld, base, LDAP_SCOPE_ONE,
filter, attrs, 0, NULL, NULL, 0, 0, &msgid );
if ( rc != LDAP_SUCCESS ) {
- do_error( ld, "ldap_search_ext" );
+ tester_ldap_error( ld, "ldap_search_ext" );
exit( EXIT_FAILURE );
}
--- /dev/null
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1999-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Howard Chu for inclusion
+ * in OpenLDAP Software.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+#include <ac/unistd.h>
+#include <ac/string.h>
+#include <ac/errno.h>
+
+#include <ldap.h>
+
+static char progname[ BUFSIZ ];
+
+void
+tester_init( const char *pname )
+{
+ snprintf( progname, sizeof( progname ), "%s PID=%d", pname, getpid() );
+}
+
+char *
+tester_uri( char *uri, char *host, int port )
+{
+ static char uribuf[ BUFSIZ ];
+
+ if ( uri != NULL ) {
+ return uri;
+ }
+
+ snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", host, port );
+
+ return uribuf;
+}
+
+void
+tester_ldap_error( LDAP *ld, const char *fname )
+{
+ int err;
+ const char *text = "Success";
+
+ ldap_get_option( ld, LDAP_OPT_RESULT_CODE, (void *)&err );
+ if ( err != LDAP_SUCCESS ) {
+ ldap_get_option( ld, LDAP_OPT_ERROR_STRING, (void *)&text );
+ }
+
+ fprintf( stderr, "%s: %s: (%d) %s\n",
+ progname, fname, err, text == NULL ? "" : text );
+}
+
+void
+tester_perror( const char *fname )
+{
+ int save_errno = errno;
+ char buf[ BUFSIZ ];
+
+ fprintf( stderr, "%s: %s: (%d) %s\n",
+ progname, fname, save_errno,
+ AC_STRERROR_R( save_errno, buf, sizeof( buf ) ) );
+}
+
--- /dev/null
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1999-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Howard Chu for inclusion
+ * in OpenLDAP Software.
+ */
+
+#ifndef SLAPD_COMMON_H
+#define SLAPD_COMMON_H
+
+extern void tester_init( const char *pname );
+extern char * tester_uri( char *uri, char *host, int port );
+extern void tester_perror( const char *fname );
+extern void tester_ldap_error( LDAP *ld, const char *fname );
+
+#endif /* SLAPD_COMMON_H */
#include <ac/unistd.h>
#include <ac/wait.h>
-#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <lutil.h>
+#include "slapd-common.h"
+
#define LOOPS 100
#define RETRIES 0
static void
-do_modify( char *uri, char *host, int port, char *manager, char *passwd,
+do_modify( char *uri, char *manager, struct berval *passwd,
char *entry, char *attr, char *value, int maxloop,
int maxretries, int delay, int friendly );
char *host = "localhost";
int port = -1;
char *manager = NULL;
- char *passwd = NULL;
+ struct berval passwd = { 0, NULL };
char *entry = NULL;
char *ava = NULL;
char *value = NULL;
int delay = 0;
int friendly = 0;
+ tester_init( "slapd-modify" );
+
while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:a:l:r:t:" )) != EOF ) {
switch( i ) {
case 'F':
break;
case 'w': /* the server managers password */
- passwd = strdup( optarg );
+ passwd.bv_val = strdup( optarg );
+ passwd.bv_len = strlen( optarg );
break;
case 'e': /* entry to modify */
while ( *value && isspace( (unsigned char) *value ))
value++;
- do_modify( uri, host, port, manager, passwd, entry, ava, value,
+ uri = tester_uri( uri, host, port );
+
+ do_modify( uri, manager, &passwd, entry, ava, value,
loops, retries, delay, friendly );
exit( EXIT_SUCCESS );
}
static void
-do_modify( char *uri, char *host, int port, char *manager,
- char *passwd, char *entry, char* attr, char* value,
+do_modify( char *uri, char *manager,
+ struct berval *passwd, char *entry, char* attr, char* value,
int maxloop, int maxretries, int delay, int friendly )
{
LDAP *ld = NULL;
mods[1] = NULL;
retry:;
- if ( uri ) {
- ldap_initialize( &ld, uri );
- } else {
- ld = ldap_init( host, port );
- }
+ ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_init" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
(long) pid, maxloop, entry );
}
- rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
+ rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
for ( ; i < maxloop; i++ ) {
mod.mod_op = LDAP_MOD_ADD;
- rc = ldap_modify_s( ld, entry, mods );
+ rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_modify" );
+ tester_ldap_error( ld, "ldap_modify_ext_s" );
switch ( rc ) {
case LDAP_TYPE_OR_VALUE_EXISTS:
/* NOTE: this likely means
}
mod.mod_op = LDAP_MOD_DELETE;
- rc = ldap_modify_s( ld, entry, mods );
+ rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_modify" );
+ tester_ldap_error( ld, "ldap_modify_ext_s" );
switch ( rc ) {
case LDAP_NO_SUCH_ATTRIBUTE:
/* NOTE: this likely means
done:;
fprintf( stderr, " PID=%ld - Modify done (%d).\n", (long) pid, rc );
- ldap_unbind( ld );
+ ldap_unbind_ext( ld, NULL, NULL );
}
#include <ac/unistd.h>
#include <ac/wait.h>
-#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <lutil.h>
+#include "slapd-common.h"
+
#define LOOPS 100
#define RETRIES 0
static void
-do_modrdn( char *uri, char *host, int port, char *manager, char *passwd,
+do_modrdn( char *uri, char *manager, struct berval *passwd,
char *entry, int maxloop, int maxretries, int delay,
int friendly );
char *host = "localhost";
int port = -1;
char *manager = NULL;
- char *passwd = NULL;
+ struct berval passwd = { 0, NULL };
char *entry = NULL;
int loops = LOOPS;
int retries = RETRIES;
int delay = 0;
int friendly = 0;
+ tester_init( "slapd-modrdn" );
+
while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:l:r:t:" )) != EOF ) {
switch( i ) {
case 'F':
break;
case 'w': /* the server managers password */
- passwd = strdup( optarg );
+ passwd.bv_val = strdup( optarg );
+ passwd.bv_len = strlen( optarg );
break;
case 'e': /* entry to rename */
}
- do_modrdn( uri, host, port, manager, passwd, entry,
+ uri = tester_uri( uri, host, port );
+
+ do_modrdn( uri, manager, &passwd, entry,
loops, retries, delay, friendly );
exit( EXIT_SUCCESS );
}
static void
-do_modrdn( char *uri, char *host, int port, char *manager,
- char *passwd, char *entry, int maxloop, int maxretries, int delay,
+do_modrdn( char *uri, char *manager,
+ struct berval *passwd, char *entry, int maxloop, int maxretries, int delay,
int friendly )
{
LDAP *ld = NULL;
int i = 0, do_retry = maxretries;
pid_t pid;
- char *DNs[2];
- char *rdns[2];
- int rc = LDAP_SUCCESS;
-
+ char *DNs[2];
+ char *rdns[2];
+ int rc = LDAP_SUCCESS;
+ char *p1, *p2;
+ int version = LDAP_VERSION3;
pid = getpid();
DNs[0] = entry;
DNs[1] = strdup( entry );
/* reverse the RDN, make new DN */
- {
- char *p1, *p2;
-
- p1 = strchr( entry, '=' ) + 1;
- p2 = strchr( p1, ',' );
-
- *p2 = '\0';
- rdns[1] = strdup( entry );
- *p2-- = ',';
-
- for (i = p1 - entry;p2 >= p1;)
- DNs[1][i++] = *p2--;
-
- DNs[1][i] = '\0';
- rdns[0] = strdup( DNs[1] );
- DNs[1][i] = ',';
- }
+ p1 = strchr( entry, '=' ) + 1;
+ p2 = strchr( p1, ',' );
+
+ *p2 = '\0';
+ rdns[1] = strdup( entry );
+ *p2-- = ',';
+
+ for (i = p1 - entry;p2 >= p1;)
+ DNs[1][i++] = *p2--;
+
+ DNs[1][i] = '\0';
+ rdns[0] = strdup( DNs[1] );
+ DNs[1][i] = ',';
retry:;
- if ( uri ) {
- ldap_initialize( &ld, uri );
- } else {
- ld = ldap_init( host, port );
- }
+ ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_init" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
- {
- int version = LDAP_VERSION3;
- (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
- &version );
- }
+ (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
- rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
+ rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
}
for ( ; i < maxloop; i++ ) {
- rc = ldap_modrdn2_s( ld, DNs[0], rdns[0], 0 );
+ rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_modrdn" );
+ tester_ldap_error( ld, "ldap_rename_s" );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
goto done;
}
}
- rc = ldap_modrdn2_s( ld, DNs[1], rdns[1], 1 );
+ rc = ldap_rename_s( ld, DNs[1], rdns[1], NULL, 1, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_modrdn" );
+ tester_ldap_error( ld, "ldap_rename_s" );
switch ( rc ) {
case LDAP_NO_SUCH_OBJECT:
/* NOTE: this likely means
done:;
fprintf( stderr, " PID=%ld - Modrdn done (%d).\n", (long) pid, rc );
- ldap_unbind( ld );
+ ldap_unbind_ext( ld, NULL, NULL );
}
#include <ac/unistd.h>
#include <ac/wait.h>
-#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <lutil.h>
+#include "slapd-common.h"
+
#define LOOPS 100
#define RETRIES 0
static void
-do_read( char *uri, char *host, int port, char *entry, int maxloop,
+do_read( char *uri, char *entry, int maxloop,
int maxretries, int delay );
static void
int retries = RETRIES;
int delay = 0;
+ tester_init( "slapd-read" );
+
while ( (i = getopt( argc, argv, "H:h:p:e:l:r:t:" )) != EOF ) {
switch( i ) {
case 'H': /* the server uri */
exit( EXIT_FAILURE );
}
- do_read( uri, host, port, entry, ( 20 * loops ), retries, delay );
+ uri = tester_uri( uri, host, port );
+
+ do_read( uri, entry, ( 20 * loops ), retries, delay );
exit( EXIT_SUCCESS );
}
static void
-do_read( char *uri, char *host, int port, char *entry, int maxloop,
+do_read( char *uri, char *entry, int maxloop,
int maxretries, int delay )
{
LDAP *ld = NULL;
char *attrs[] = { "1.1", NULL };
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
+ int version = LDAP_VERSION3;
+ struct berval passwd = { 0, "" };
retry:;
- if ( uri ) {
- ldap_initialize( &ld, uri );
- } else {
- ld = ldap_init( host, port );
- }
+ ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_init" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
- {
- int version = LDAP_VERSION3;
- (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
- &version );
- }
+ (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
- rc = ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE );
+ rc = ldap_sasl_bind_s( ld, NULL, LDAP_SASL_SIMPLE, &passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
for ( ; i < maxloop; i++ ) {
LDAPMessage *res;
- rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
- NULL, attrs, 1, &res );
+ rc = ldap_search_ext_s( ld, entry, LDAP_SCOPE_BASE,
+ NULL, attrs, 1, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_read" );
+ tester_ldap_error( ld, "ldap_search_ext_s" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
fprintf( stderr, " PID=%ld - Read done (%d).\n", (long) pid, rc );
- ldap_unbind( ld );
+ ldap_unbind_ext( ld, NULL, NULL );
}
#include <ac/unistd.h>
#include <ac/wait.h>
-#define LDAP_DEPRECATED 1
#include <ldap.h>
#include <lutil.h>
+#include "slapd-common.h"
+
#define LOOPS 100
#define RETRIES 0
static void
-do_search( char *uri, char *host, int port, char *manager, char *passwd,
+do_search( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, int maxloop, int maxretries, int delay );
static void
char *host = "localhost";
int port = -1;
char *manager = NULL;
- char *passwd = NULL;
+ struct berval passwd = { 0, NULL };
char *sbase = NULL;
char *filter = NULL;
int loops = LOOPS;
int retries = RETRIES;
int delay = 0;
+ tester_init( "slapd-search" );
+
while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:r:t:" )) != EOF ) {
switch( i ) {
case 'H': /* the server uri */
break;
case 'w': /* the server managers password */
- passwd = strdup( optarg );
+ passwd.bv_val = strdup( optarg );
+ passwd.bv_len = strlen( optarg );
break;
case 'b': /* file with search base */
}
- do_search( uri, host, port, manager, passwd, sbase, filter,
+ uri = tester_uri( uri, host, port );
+
+ do_search( uri, manager, &passwd, sbase, filter,
( 10 * loops ), retries, delay );
exit( EXIT_SUCCESS );
}
static void
-do_search( char *uri, char *host, int port, char *manager, char *passwd,
+do_search( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, int maxloop, int maxretries, int delay )
{
LDAP *ld = NULL;
char *attrs[] = { "cn", "sn", NULL };
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
+ int version = LDAP_VERSION3;
retry:;
- if ( uri ) {
- ldap_initialize( &ld, uri );
- } else {
- ld = ldap_init( host, port );
- }
+ ldap_initialize( &ld, uri );
if ( ld == NULL ) {
- perror( "ldap_init" );
+ tester_perror( "ldap_initialize" );
exit( EXIT_FAILURE );
}
- {
- int version = LDAP_VERSION3;
- (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
- &version );
- }
+ (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
(long) pid, maxloop, sbase, filter );
}
- rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
+ rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_bind" );
+ tester_ldap_error( ld, "ldap_sasl_bind_s" );
switch ( rc ) {
case LDAP_BUSY:
case LDAP_UNAVAILABLE:
for ( ; i < maxloop; i++ ) {
LDAPMessage *res;
- rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
- filter, attrs, 0, &res );
+ rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
+ filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
if ( rc != LDAP_SUCCESS ) {
- ldap_perror( ld, "ldap_search" );
+ tester_ldap_error( ld, "ldap_search_ext_s" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
ldap_unbind_ext( ld, NULL, NULL );
do_retry--;
#include "ldap_defaults.h"
#include "lutil.h"
+#include "ldap.h"
+#include "slapd-common.h"
#define SEARCHCMD "slapd-search"
#define READCMD "slapd-read"
int banum;
char bcmd[MAXPATHLEN];
+ tester_init( "slapd-tester" );
+
while ( (i = getopt( argc, argv, "D:d:FH:h:j:l:P:p:r:t:w:" )) != EOF ) {
switch( i ) {
case 'D': /* slapd manager */
args = arg2; }
#endif
execvp( prog, args );
- fprintf( stderr, "%s: ", prog );
- perror( "execv" );
+ tester_perror( "execvp" );
exit( EXIT_FAILURE );
break;
case -1: /* trouble */
- fprintf( stderr, "Could not fork to run %s\n", prog );
- perror( "fork" );
+ tester_perror( "fork" );
break;
default: /* parent */
rc = _spawnvp( _P_NOWAIT, prog, args );
if ( rc == -1 ) {
- fprintf( stderr, "%s: ", prog );
- perror("spawnvp");
+ tester_perror( "_spawnvp" );
} else {
children[nkids++] = (HANDLE)rc;
}