int force, int chaserefs, int noinit, LDAP **ldp );
static int
-do_base( char *uri, struct berval *base, struct berval *pass, char *pwattr,
+do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr,
int maxloop, int force, int chaserefs, int noinit, int delay );
/* This program can be invoked two ways: if -D is used to specify a Bind DN,
exit( EXIT_FAILURE );
}
-static char *filter = "(objectClass=person)";
-
int
main( int argc, char **argv )
{
char *uri = NULL;
char *host = "localhost";
char *dn = NULL;
- struct berval base = { 0, NULL };
+ char *base = NULL;
+ char *filter = "(objectClass=person)";
struct berval pass = { 0, NULL };
char *pwattr = NULL;
int port = -1;
break;
case 'b': /* base DN of a tree of user DNs */
- ber_str2bv( optarg, 0, 0, &base );
+ base = optarg;
break;
case 'C':
uri = tester_uri( uri, host, port );
for ( i = 0; i < outerloops; i++ ) {
- if ( base.bv_val != NULL ) {
- do_base( uri, &base, &pass, pwattr, loops,
+ if ( base != NULL ) {
+ do_base( uri, dn, &pass, base, filter, pwattr, loops,
force, chaserefs, noinit, delay );
} else {
do_bind( uri, dn, &pass, loops,
static int
-do_base( char *uri, struct berval *base, struct berval *pass, char *pwattr,
+do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr,
int maxloop, int force, int chaserefs, int noinit, int delay )
{
LDAP *ld = NULL;
struct timeval beg, end;
#endif
int version = LDAP_VERSION3;
- struct berval pw = { 0, NULL };
char *nullstr = "";
srand(pid);
(void) ldap_set_option( ld, LDAP_OPT_REFERRALS,
chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF );
- rc = ldap_sasl_bind_s( ld, NULL, LDAP_SASL_SIMPLE, &pw, NULL, NULL, NULL );
+ rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
exit( EXIT_FAILURE );
}
fprintf( stderr, "PID=%ld - Bind(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n",
- (long) pid, maxloop, base->bv_val, filter, pwattr );
+ (long) pid, maxloop, base, filter, pwattr );
if ( pwattr != NULL ) {
attrs[ 0 ] = pwattr;
}
- rc = ldap_search_ext( ld, base->bv_val, LDAP_SCOPE_SUBTREE,
+ rc = ldap_search_ext( ld, base, LDAP_SCOPE_SUBTREE,
filter, attrs, 0, NULL, NULL, 0, 0, &msgid );
if ( rc != LDAP_SUCCESS ) {
tester_ldap_error( ld, "ldap_search_ext", NULL );
creds = realloc( creds, (ndns + 1)*sizeof(struct berval) );
if ( values == NULL ) {
novals:;
- if ( pass != NULL ) {
- ber_dupbv( &creds[ndns], pass );
-
- } else {
- creds[ndns].bv_len = 0;
- creds[ndns].bv_val = nullstr;
- }
+ creds[ndns].bv_len = 0;
+ creds[ndns].bv_val = nullstr;
} else {
static struct berval cleartext = BER_BVC( "{CLEARTEXT} " );
}
fprintf( stderr, " PID=%ld - Bind base=\"%s\" filter=\"%s\" got %d values.\n",
- (long) pid, base->bv_val, filter, ndns );
+ (long) pid, base, filter, ndns );
/* Ok, got list of DNs, now start binding to each */
for ( i = 0; i < maxloop; i++ ) {
int j, k;
- struct berval *cred = pass;
+ struct berval cred = { 0, NULL };
for ( j = 0, k = 0; k < ndns; k++) {
j = rand() % ndns;
}
if ( creds && !BER_BVISEMPTY( &creds[j] ) ) {
- cred = &creds[j];
+ cred = creds[j];
}
- if ( do_bind( uri, dns[j], cred, 1, force, chaserefs, noinit, &ld )
+ if ( do_bind( uri, dns[j], &cred, 1, force, chaserefs, noinit, &ld )
&& !force )
{
break;
if ( DOREQ( bnum, j ) ) {
int jj = j % bnum;
- bargs[banum - 4] = breqs[jj];
- bargs[banum - 2] = bcreds[jj];
- bargs[banum - 1] = NULL;
if ( battrs[jj] != NULL ) {
- bargs[banum - 5] = "-b";
- bargs[banum - 3] = "-f";
- bargs[banum - 1] = "-a";
- bargs[banum] = battrs[jj];
+ bargs[banum - 4] = manager ? manager : "";
+ bargs[banum - 2] = passwd ? passwd : "";
+
+ bargs[banum - 1] = "-b";
+ bargs[banum] = breqs[jj];
+ bargs[banum + 1] = "-f";
+ bargs[banum + 2] = bcreds[jj];
+ bargs[banum + 3] = "-a";
+ bargs[banum + 4] = battrs[jj];
+ } else {
+ bargs[banum - 4] = breqs[jj];
+ bargs[banum - 2] = bcreds[jj];
+ bargs[banum - 1] = NULL;
}
fork_child( bcmd, bargs );
- bargs[banum - 5] = "-D";
- bargs[banum - 3] = "-w";
+ bargs[banum - 1] = NULL;
}
}