get_add_entry( char *filename, LDAPMod ***mods );
static void
-do_addel( char *host, int port, char *manager, char *passwd,
+do_addel( char *uri, char *host, int port, char *manager, char *passwd,
char *dn, LDAPMod **attrs, int maxloop );
static void
{
int i;
char *host = "localhost";
+ char *uri = NULL;
int port = -1;
char *manager = NULL;
char *passwd = NULL;
int loops = LOOPS;
LDAPMod **attrs = NULL;
- while ( (i = getopt( argc, argv, "h:p:D:w:f:l:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "H:h:p:D:w:f:l:" )) != EOF ) {
switch( i ) {
+ case 'H': /* the server's URI */
+ uri = strdup( optarg );
+ break;
case 'h': /* the servers host */
host = strdup( optarg );
break;
}
}
- if (( filename == NULL ) || ( port == -1 ) ||
+ if (( filename == NULL ) || ( port == -1 && uri == NULL ) ||
( manager == NULL ) || ( passwd == NULL ))
usage( argv[0] );
}
- do_addel( host, port, manager, passwd, entry, attrs, loops );
+ do_addel( uri, host, port, manager, passwd, entry, attrs, loops );
exit( EXIT_SUCCESS );
}
static void
do_addel(
+ char *uri,
char *host,
int port,
char *manager,
int maxloop
)
{
- LDAP *ld;
+ LDAP *ld = NULL;
int i;
pid_t pid = getpid();
- if (( ld = ldap_init( host, port )) == NULL ) {
+ if ( uri ) {
+ ldap_initialize( &ld, uri );
+ } else {
+ ld = ldap_init( host, port );
+ }
+ if ( ld == NULL ) {
perror( "ldap_init" );
exit( EXIT_FAILURE );
}
}
/* wait a second for the add to really complete */
- sleep( 1 );
+ /* sleep( 1 ); */
/* now delete the entry again */
if ( ldap_delete_s( ld, entry ) != LDAP_SUCCESS ) {
#define LOOPS 100
static void
-do_read( char *host, int port, char *entry, int maxloop );
+do_read( char *uri, char *host, int port, char *entry, int maxloop );
static void
usage( char *name )
main( int argc, char **argv )
{
int i;
+ char *uri = NULL;
char *host = "localhost";
int port = -1;
char *entry = NULL;
int loops = LOOPS;
- while ( (i = getopt( argc, argv, "h:p:e:l:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "H:h:p:e:l:" )) != EOF ) {
switch( i ) {
+ case 'H': /* the server uri */
+ uri = strdup( optarg );
+ break;
case 'h': /* the servers host */
host = strdup( optarg );
break;
}
}
- if (( entry == NULL ) || ( port == -1 ))
+ if (( entry == NULL ) || ( port == -1 && uri == NULL ))
usage( argv[0] );
if ( *entry == '\0' ) {
}
- do_read( host, port, entry, ( 20 * loops ));
+ do_read( uri, host, port, entry, ( 20 * loops ));
exit( EXIT_SUCCESS );
}
static void
-do_read( char *host, int port, char *entry, int maxloop )
+do_read( char *uri, char *host, int port, char *entry, int maxloop )
{
- LDAP *ld;
+ LDAP *ld = NULL;
int i;
char *attrs[] = { "1.1", NULL };
pid_t pid = getpid();
- if (( ld = ldap_init( host, port )) == NULL ) {
+ if ( uri ) {
+ ldap_initialize( &ld, uri );
+ } else {
+ ld = ldap_init( host, port );
+ }
+ if ( ld == NULL ) {
perror( "ldap_init" );
exit( EXIT_FAILURE );
}
#define LOOPS 100
static void
-do_search( char *host, int port, char *sbase, char *filter, int maxloop );
+do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxloop );
static void
usage( char *name )
main( int argc, char **argv )
{
int i;
+ char *uri = NULL;
char *host = "localhost";
int port = -1;
char *sbase = NULL;
char *filter = NULL;
int loops = LOOPS;
- while ( (i = getopt( argc, argv, "h:p:b:f:l:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "H:h:p:b:f:l:" )) != EOF ) {
switch( i ) {
+ case 'H': /* the server uri */
+ uri = strdup( optarg );
+ break;
case 'h': /* the servers host */
host = strdup( optarg );
break;
}
}
- if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 ))
+ if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 && uri == NULL ))
usage( argv[0] );
if ( *filter == '\0' ) {
}
- do_search( host, port, sbase, filter, ( 10 * loops ));
+ do_search( uri, host, port, sbase, filter, ( 10 * loops ));
exit( EXIT_SUCCESS );
}
static void
-do_search( char *host, int port, char *sbase, char *filter, int maxloop )
+do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxloop )
{
- LDAP *ld;
+ LDAP *ld = NULL;
int i;
char *attrs[] = { "cn", "sn", NULL };
pid_t pid = getpid();
- if (( ld = ldap_init( host, port )) == NULL ) {
+ if ( uri ) {
+ ldap_initialize( &ld, uri );
+ } else {
+ ld = ldap_init( host, port );
+ }
+ if ( ld == NULL ) {
perror( "ldap_init" );
exit( EXIT_FAILURE );
}
main( int argc, char **argv )
{
int i, j;
+ char *uri = NULL;
char *host = "localhost";
char *port = NULL;
char *manager = NULL;
int aanum;
char acmd[MAXPATHLEN];
- while ( (i = getopt( argc, argv, "h:p:D:w:b:d:j:l:P:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "H:h:p:D:w:b:d:j:l:P:" )) != EOF ) {
switch( i ) {
+ case 'H': /* slapd uri */
+ uri = strdup( optarg );
+ break;
+
case 'h': /* slapd host */
host = strdup( optarg );
break;
}
}
- if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL ) ||
+ if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL && uri == NULL ) ||
( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL ))
usage( argv[0] );
snprintf( scmd, sizeof scmd, "%s" LDAP_DIRSEP SEARCHCMD,
progdir );
sargs[sanum++] = scmd;
- sargs[sanum++] = "-h";
- sargs[sanum++] = host;
- sargs[sanum++] = "-p";
- sargs[sanum++] = port;
+ if ( uri ) {
+ sargs[sanum++] = "-H";
+ sargs[sanum++] = uri;
+ } else {
+ sargs[sanum++] = "-h";
+ sargs[sanum++] = host;
+ sargs[sanum++] = "-p";
+ sargs[sanum++] = port;
+ }
sargs[sanum++] = "-b";
sargs[sanum++] = sbase;
sargs[sanum++] = "-l";
snprintf( rcmd, sizeof rcmd, "%s" LDAP_DIRSEP READCMD,
progdir );
rargs[ranum++] = rcmd;
- rargs[ranum++] = "-h";
- rargs[ranum++] = host;
- rargs[ranum++] = "-p";
- rargs[ranum++] = port;
+ if ( uri ) {
+ rargs[ranum++] = "-H";
+ rargs[ranum++] = uri;
+ } else {
+ rargs[ranum++] = "-h";
+ rargs[ranum++] = host;
+ rargs[ranum++] = "-p";
+ rargs[ranum++] = port;
+ }
rargs[ranum++] = "-l";
rargs[ranum++] = loops;
rargs[ranum++] = "-e";
snprintf( acmd, sizeof acmd, "%s" LDAP_DIRSEP ADDCMD,
progdir );
aargs[aanum++] = acmd;
- aargs[aanum++] = "-h";
- aargs[aanum++] = host;
- aargs[aanum++] = "-p";
- aargs[aanum++] = port;
+ if ( uri ) {
+ aargs[aanum++] = "-H";
+ aargs[aanum++] = uri;
+ } else {
+ aargs[aanum++] = "-h";
+ aargs[aanum++] = host;
+ aargs[aanum++] = "-p";
+ aargs[aanum++] = port;
+ }
aargs[aanum++] = "-D";
aargs[aanum++] = manager;
aargs[aanum++] = "-w";