int
main( int argc, char **argv )
{
- char *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
+ char *usage = "usage: %s [-n] [-v] [-k] [-W] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
char buf[ 4096 ];
FILE *fp;
- int i, rc, authmethod;
+ int i, rc, authmethod, want_bindpw;
- not = verbose = contoper = 0;
+ not = verbose = contoper = want_bindpw = 0;
fp = NULL;
authmethod = LDAP_AUTH_SIMPLE;
- while (( i = getopt( argc, argv, "nvkKch:p:D:w:d:f:" )) != EOF ) {
+ while (( i = getopt( argc, argv, "WnvkKch:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
case 'k': /* kerberos bind */
#ifdef HAVE_KERBEROS
case 'v': /* verbose mode */
verbose++;
break;
+ case 'W':
+ want_bindpw++;
+ break;
default:
fprintf( stderr, usage, argv[0] );
exit( 1 );
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
}
+ if (want_bindpw)
+ passwd = getpass("Enter LDAP Password: ");
+
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );
{
char *infile, *rbuf, *start, *p, *q;
FILE *fp;
- int rc, i, use_ldif, authmethod;
- char *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
+ int rc, i, use_ldif, authmethod, want_bindpw;
+ char *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
prog = argv[ 0 ];
new = ( strcmp( prog, "ldapadd" ) == 0 );
infile = NULL;
- not = verbose = valsfromfiles = 0;
+ not = verbose = valsfromfiles = want_bindpw = 0;
authmethod = LDAP_AUTH_SIMPLE;
- while (( i = getopt( argc, argv, "FabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
+ while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
case 'a': /* add */
new = 1;
case 'v': /* verbose mode */
verbose++;
break;
+ case 'W':
+ want_bindpw++;
+ break;
default:
fprintf( stderr, usage, prog );
exit( 1 );
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
+ if (want_bindpw)
+ passwd = getpass("Enter LDAP Password: ");
+
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );
int
main(int argc, char **argv)
{
- char *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
+ char *usage = "usage: %s [-nvkWc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
char *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
FILE *fp;
- int rc, i, remove, havedn, authmethod;
+ int rc, i, remove, havedn, authmethod, want_bindpw;
infile = NULL;
- not = contoper = verbose = remove = 0;
+ not = contoper = verbose = remove = want_bindpw = 0;
authmethod = LDAP_AUTH_SIMPLE;
myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname;
- while (( i = getopt( argc, argv, "kKcnvrh:p:D:w:d:f:" )) != EOF ) {
+ while (( i = getopt( argc, argv, "WkKcnvrh:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
case 'k': /* kerberos bind */
#ifdef HAVE_KERBEROS
case 'r': /* remove old RDN */
remove++;
break;
+ case 'W':
+ want_bindpw++;
+ break;
default:
fprintf( stderr, usage, argv[0] );
exit( 1 );
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
+ if (want_bindpw)
+ passwd = getpass("Enter LDAP Password: ");
+
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );
fprintf( stderr, " -z size lim\tsize limit (in entries) for search\n" );
fprintf( stderr, " -D binddn\tbind dn\n" );
fprintf( stderr, " -w passwd\tbind passwd (for simple authentication)\n" );
+ fprintf( stderr, " -W\t\tprompt for bind passwd\n" );
#ifdef HAVE_KERBEROS
fprintf( stderr, " -k\t\tuse Kerberos instead of Simple Password authentication\n" );
#endif
char *infile, *filtpattern, **attrs, line[ BUFSIZ ];
FILE *fp;
int rc, i, first, scope, deref, attrsonly;
- int referrals, timelimit, sizelimit, authmethod;
+ int referrals, timelimit, sizelimit, authmethod, want_bindpw;
LDAP *ld;
infile = NULL;
deref = verbose = allow_binary = not = vals2tmp =
- attrsonly = ldif = 0;
+ attrsonly = ldif = want_bindpw = 0;
referrals = (int) LDAP_OPT_ON;
sizelimit = timelimit = 0;
scope = LDAP_SCOPE_SUBTREE;
authmethod = LDAP_AUTH_SIMPLE;
- while (( i = getopt( argc, argv, "KknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:")) != EOF ) {
+ while (( i = getopt( argc, argv, "WKknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:")) != EOF ) {
switch( i ) {
case 'n': /* do Not do any searches */
++not;
case 'S': /* sort attribute */
sortattr = strdup( optarg );
break;
+ case 'W':
+ want_bindpw++;
+ break;
default:
usage( argv[0] );
}
/* set option error */
}
+ if (want_bindpw)
+ passwd = getpass("Enter LDAP Password: ");
+
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );