mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Add slapd-bind to Makefile, update bind notes.
This commit is contained in:
parent
9edea08357
commit
382a0e8d24
2 changed files with 28 additions and 11 deletions
|
|
@ -14,10 +14,10 @@
|
||||||
## <http://www.OpenLDAP.org/license.html>.
|
## <http://www.OpenLDAP.org/license.html>.
|
||||||
|
|
||||||
PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel slapd-modrdn \
|
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 \
|
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_INCDIR= ../../include
|
||||||
LDAP_LIBDIR= ../../libraries
|
LDAP_LIBDIR= ../../libraries
|
||||||
|
|
@ -47,3 +47,6 @@ slapd-modrdn: slapd-modrdn.o $(XLIBS)
|
||||||
|
|
||||||
slapd-modify: slapd-modify.o $(XLIBS)
|
slapd-modify: slapd-modify.o $(XLIBS)
|
||||||
$(LTLINK) -o $@ slapd-modify.o $(LIBS)
|
$(LTLINK) -o $@ slapd-modify.o $(LIBS)
|
||||||
|
|
||||||
|
slapd-bind: slapd-bind.o $(XLIBS)
|
||||||
|
$(LTLINK) -o $@ slapd-bind.o $(LIBS)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* <http://www.OpenLDAP.org/license.html>.
|
* <http://www.OpenLDAP.org/license.html>.
|
||||||
*/
|
*/
|
||||||
/* ACKNOWLEDGEMENTS:
|
/* ACKNOWLEDGEMENTS:
|
||||||
* This work was initially developed by Kurt Spanier for inclusion
|
* This work was initially developed by Howard Chu for inclusion
|
||||||
* in OpenLDAP Software.
|
* in OpenLDAP Software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -36,12 +36,19 @@
|
||||||
|
|
||||||
#define LOOPS 100
|
#define LOOPS 100
|
||||||
|
|
||||||
static void
|
static int
|
||||||
do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop );
|
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 );
|
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
|
static void
|
||||||
usage( char *name )
|
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 )
|
do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop )
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
LDAP *ld = NULL;
|
||||||
int i;
|
int i, rc;
|
||||||
char *attrs[] = { "1.1", NULL };
|
char *attrs[] = { "1.1", NULL };
|
||||||
pid_t pid = getpid();
|
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++ ) {
|
for ( i = 0; i < maxloop; i++ ) {
|
||||||
LDAPMessage *res;
|
LDAPMessage *res;
|
||||||
int rc;
|
|
||||||
|
|
||||||
if ( uri ) {
|
if ( uri ) {
|
||||||
ldap_initialize( &ld, 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 ) {
|
if ( ld == NULL ) {
|
||||||
perror( "ldap_init" );
|
perror( "ldap_init" );
|
||||||
|
rc = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,10 +162,11 @@ do_bind( char *uri, char *host, int port, char *dn, char *pass, int maxloop )
|
||||||
if ( maxloop > 1 )
|
if ( maxloop > 1 )
|
||||||
fprintf( stderr, " PID=%ld - Bind done.\n", (long) pid );
|
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 )
|
do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
|
||||||
{
|
{
|
||||||
LDAP *ld = NULL;
|
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 **rdns = NULL;
|
||||||
char *attrs[] = { "dn", NULL };
|
char *attrs[] = { "dn", NULL };
|
||||||
int nrdns = 0;
|
int nrdns = 0;
|
||||||
|
time_t beg, end;
|
||||||
|
|
||||||
srand(pid);
|
srand(pid);
|
||||||
|
|
||||||
|
|
@ -196,7 +205,7 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
|
||||||
exit( EXIT_FAILURE );
|
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 );
|
filter, attrs, 0, NULL, NULL, 0, 0, &msgid );
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
ldap_perror( ld, "ldap_search_ex" );
|
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 );
|
ldap_unbind( ld );
|
||||||
|
|
||||||
|
beg = time(0L);
|
||||||
/* Ok, got list of RDNs, now start binding to each */
|
/* Ok, got list of RDNs, now start binding to each */
|
||||||
for (i=0; i<maxloop; i++) {
|
for (i=0; i<maxloop; i++) {
|
||||||
char dn[BUFSIZ], *ptr;
|
char dn[BUFSIZ], *ptr;
|
||||||
|
|
@ -242,6 +252,10 @@ do_base( char *uri, char *host, int port, char *base, char *pass, int maxloop )
|
||||||
ptr = lutil_strcopy(dn, rdns[j]);
|
ptr = lutil_strcopy(dn, rdns[j]);
|
||||||
*ptr++ = ',';
|
*ptr++ = ',';
|
||||||
strcpy(ptr, base);
|
strcpy(ptr, base);
|
||||||
do_bind( uri, host, port, dn, pass, 1 );
|
if ( do_bind( uri, host, port, dn, pass, 1 ))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
end = time(0L);
|
||||||
|
fprintf( stderr, "Done %d Binds in %d seconds.\n", i, end - beg );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue