mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
further cleanup
This commit is contained in:
parent
f4c578cb31
commit
1b95d308b9
1 changed files with 24 additions and 9 deletions
|
|
@ -43,7 +43,7 @@ static int
|
||||||
do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int noinit, LDAP **ldp );
|
do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int noinit, LDAP **ldp );
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit );
|
do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit, int delay );
|
||||||
|
|
||||||
/* This program can be invoked two ways: if -D is used to specify a Bind DN,
|
/* 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
|
* that DN will be used repeatedly for all of the Binds. If instead -b is used
|
||||||
|
|
@ -55,7 +55,7 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f
|
||||||
static void
|
static void
|
||||||
usage( char *name )
|
usage( char *name )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "usage: %s [-h <host>] -p port (-D <dn>|-b <baseDN> [-f <searchfilter>]) -w <passwd> [-l <loops>] [-F] [-I]\n",
|
fprintf( stderr, "usage: %s [-h <host>] -p port (-D <dn>|-b <baseDN> [-f <searchfilter>]) -w <passwd> [-l <loops>] [-F] [-I] [-t delay]\n",
|
||||||
name );
|
name );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
@ -75,10 +75,11 @@ main( int argc, char **argv )
|
||||||
int loops = LOOPS;
|
int loops = LOOPS;
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int noinit = 0;
|
int noinit = 0;
|
||||||
|
int delay = 0;
|
||||||
|
|
||||||
tester_init( "slapd-bind" );
|
tester_init( "slapd-bind" );
|
||||||
|
|
||||||
while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:f:FI" )) != EOF ) {
|
while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:f:FIt:" )) != EOF ) {
|
||||||
switch( i ) {
|
switch( i ) {
|
||||||
case 'b': /* base DN of a tree of user DNs */
|
case 'b': /* base DN of a tree of user DNs */
|
||||||
ber_str2bv( optarg, 0, 0, &base );
|
ber_str2bv( optarg, 0, 0, &base );
|
||||||
|
|
@ -126,6 +127,13 @@ main( int argc, char **argv )
|
||||||
noinit++;
|
noinit++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
/* sleep between binds */
|
||||||
|
if ( lutil_atoi( &delay, optarg ) != 0 ) {
|
||||||
|
usage( argv[0] );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage( argv[0] );
|
usage( argv[0] );
|
||||||
break;
|
break;
|
||||||
|
|
@ -139,7 +147,7 @@ main( int argc, char **argv )
|
||||||
uri = tester_uri( uri, host, port );
|
uri = tester_uri( uri, host, port );
|
||||||
|
|
||||||
if ( base.bv_val != NULL ) {
|
if ( base.bv_val != NULL ) {
|
||||||
do_base( uri, &base, &pass, ( 20 * loops ), force, noinit );
|
do_base( uri, &base, &pass, ( 20 * loops ), force, noinit, delay );
|
||||||
} else {
|
} else {
|
||||||
do_bind( uri, dn, &pass, ( 20 * loops ), force, noinit, NULL );
|
do_bind( uri, dn, &pass, ( 20 * loops ), force, noinit, NULL );
|
||||||
}
|
}
|
||||||
|
|
@ -201,13 +209,13 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int n
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( maxloop > 1 ) {
|
if ( maxloop > 1 ) {
|
||||||
fprintf( stderr, " PID=%ld - Bind done.\n", (long) pid );
|
fprintf( stderr, " PID=%ld - Bind done (%d).\n", (long) pid, rc );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ldp ) {
|
if ( ldp ) {
|
||||||
*ldp = ld;
|
*ldp = ld;
|
||||||
|
|
||||||
} else {
|
} else if (ld != NULL ) {
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
ldap_unbind_ext( ld, NULL, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +224,7 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, int force, int n
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit )
|
do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int force, int noinit, int delay )
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -288,8 +296,6 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f
|
||||||
ldap_msgfree( res );
|
ldap_msgfree( res );
|
||||||
if ( done ) break;
|
if ( done ) break;
|
||||||
}
|
}
|
||||||
ldap_unbind_ext( ld, NULL, NULL );
|
|
||||||
ld = NULL;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
beg = GetTickCount();
|
beg = GetTickCount();
|
||||||
|
|
@ -323,6 +329,15 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f
|
||||||
if ( do_bind( uri, dn, pass, 1, force, noinit, &ld ) && !force ) {
|
if ( do_bind( uri, dn, pass, 1, force, noinit, &ld ) && !force ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( delay ) {
|
||||||
|
sleep( delay );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ld != NULL ) {
|
||||||
|
ldap_unbind_ext( ld, NULL, NULL );
|
||||||
|
ld = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue