From: Howard Chu Date: Sun, 30 Oct 2005 08:57:06 +0000 (+0000) Subject: Add slapd-bind to Makefile, update bind notes. X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~165 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=382a0e8d246c3e38d1824344b2bd35fe35dcd0bf;p=openldap Add slapd-bind to Makefile, update bind notes. --- diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in index 39011cc1ec..052b483cba 100644 --- a/tests/progs/Makefile.in +++ b/tests/progs/Makefile.in @@ -14,10 +14,10 @@ ## . PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel slapd-modrdn \ - slapd-modify + slapd-modify slapd-bind SRCS = slapd-tester.c slapd-search.c slapd-read.c slapd-addel.c \ - slapd-modrdn.c slapd-modify.c + slapd-modrdn.c slapd-modify.c slapd-bind.c LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries @@ -47,3 +47,6 @@ slapd-modrdn: slapd-modrdn.o $(XLIBS) slapd-modify: slapd-modify.o $(XLIBS) $(LTLINK) -o $@ slapd-modify.o $(LIBS) + +slapd-bind: slapd-bind.o $(XLIBS) + $(LTLINK) -o $@ slapd-bind.o $(LIBS) diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index 8c9634eb09..e471c350eb 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -13,7 +13,7 @@ * . */ /* ACKNOWLEDGEMENTS: - * This work was initially developed by Kurt Spanier for inclusion + * This work was initially developed by Howard Chu for inclusion * in OpenLDAP Software. */ @@ -36,12 +36,19 @@ #define LOOPS 100 -static void +static int do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop ); -static void +static int do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop ); +/* This program can be invoked two ways: if -D is used to specify a Bind DN, + * that DN will be used repeatedly for all of the Binds. If instead -b is used + * to specify a base DN, a search will be done for all "person" objects under + * that base DN. Then DNs from this list will be randomly selected for each + * Bind request. All of the users must have identical passwords. Also it is + * assumed that the users are all onelevel children of the base. + */ static void usage( char *name ) { @@ -110,11 +117,11 @@ main( int argc, char **argv ) } -static void +static int do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop ) { LDAP *ld = NULL; - int i; + int i, rc; char *attrs[] = { "1.1", NULL }; pid_t pid = getpid(); @@ -124,7 +131,6 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop ) for ( i = 0; i < maxloop; i++ ) { LDAPMessage *res; - int rc; if ( uri ) { ldap_initialize( &ld, uri ); @@ -133,6 +139,7 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop ) } if ( ld == NULL ) { perror( "ldap_init" ); + rc = -1; break; } @@ -155,10 +162,11 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop ) if ( maxloop > 1 ) fprintf( stderr, " PID=%ld - Bind done.\n", (long) pid ); + return rc; } -static void +static int do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop ) { LDAP *ld = NULL; @@ -170,6 +178,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop ) char **rdns = NULL; char *attrs[] = { "dn", NULL }; int nrdns = 0; + time_t beg, end; srand(pid); @@ -196,7 +205,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop ) exit( EXIT_FAILURE ); } - rc = ldap_search_ext( ld, base, LDAP_SCOPE_SUBTREE, + rc = ldap_search_ext( ld, base, LDAP_SCOPE_ONE, filter, attrs, 0, NULL, NULL, 0, 0, &msgid ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_search_ex" ); @@ -235,6 +244,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop ) } ldap_unbind( ld ); + beg = time(0L); /* Ok, got list of RDNs, now start binding to each */ for (i=0; i