Add support for -P protocol_version.

This commit is contained in:
Dave Storey 1998-12-27 14:08:46 +00:00
parent 77edee0260
commit 61b430be33
10 changed files with 110 additions and 11 deletions

View file

@ -30,16 +30,17 @@ static int dodelete LDAP_P((
int
main( int argc, char **argv )
{
char *usage = "usage: %s [-n] [-v] [-k] [-W] [-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 version] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
char buf[ 4096 ];
FILE *fp;
int i, rc, authmethod, want_bindpw, debug;
int i, rc, authmethod, want_bindpw, version, debug;
not = verbose = contoper = want_bindpw = debug = 0;
fp = NULL;
authmethod = LDAP_AUTH_SIMPLE;
version = LDAP_VERSION2;
while (( i = getopt( argc, argv, "WnvkKch:p:D:w:d:f:" )) != EOF ) {
while (( i = getopt( argc, argv, "WnvkKch:P:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
case 'k': /* kerberos bind */
#ifdef HAVE_KERBEROS
@ -88,6 +89,17 @@ main( int argc, char **argv )
case 'W':
want_bindpw++;
break;
case 'P':
switch(optarg[0])
{
case '2':
version = LDAP_VERSION2;
break;
case '3':
version = LDAP_VERSION3;
break;
}
break;
default:
fprintf( stderr, usage, argv[0] );
exit( 1 );
@ -119,6 +131,8 @@ main( int argc, char **argv )
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );

View file

@ -68,8 +68,8 @@ main( int argc, char **argv )
{
char *infile, *rbuf, *start, *p, *q;
FILE *fp;
int rc, i, use_ldif, authmethod, want_bindpw, debug;
char *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
int rc, i, use_ldif, authmethod, version, want_bindpw, debug;
char *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-P version] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
prog = argv[ 0 ];
@ -81,6 +81,7 @@ main( int argc, char **argv )
infile = NULL;
not = verbose = valsfromfiles = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
version = LDAP_VERSION2;
while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
@ -140,6 +141,17 @@ main( int argc, char **argv )
case 'W':
want_bindpw++;
break;
case 'P':
switch(optarg[0])
{
case '2':
version = LDAP_VERSION2;
break;
case '3':
version = LDAP_VERSION3;
break;
}
break;
default:
fprintf( stderr, usage, prog );
exit( 1 );
@ -181,6 +193,8 @@ main( int argc, char **argv )
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );

View file

@ -32,18 +32,19 @@ static int domodrdn LDAP_P((
int
main(int argc, char **argv)
{
char *usage = "usage: %s [-nvkWc] [-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 version] [-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, want_bindpw, debug;
int rc, i, remove, havedn, authmethod, version, want_bindpw, debug;
infile = NULL;
not = contoper = verbose = remove = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
version = LDAP_VERSION2;
myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname;
while (( i = getopt( argc, argv, "WkKcnvrh:p:D:w:d:f:" )) != EOF ) {
while (( i = getopt( argc, argv, "WkKcnvrh:P:p:D:w:d:f:" )) != EOF ) {
switch( i ) {
case 'k': /* kerberos bind */
#ifdef HAVE_KERBEROS
@ -92,6 +93,17 @@ main(int argc, char **argv)
case 'W':
want_bindpw++;
break;
case 'P':
switch(optarg[0])
{
case '2':
version = LDAP_VERSION2;
break;
case '3':
version = LDAP_VERSION3;
break;
}
break;
default:
fprintf( stderr, usage, argv[0] );
exit( 1 );
@ -143,6 +155,8 @@ main(int argc, char **argv)
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );

View file

@ -331,6 +331,7 @@ usage (char *s)
#endif
fprintf (stderr, " -l time\ttime limit\n");
fprintf (stderr, " -n\t\tmake no modifications\n");
fprintf (stderr, " -P version\tprotocol version (2 or 3)\n");
fprintf (stderr, " -p port\tldap port\n");
fprintf (stderr, " -s scope\tsearch scope: base, one, sub (default: sub)\n");
fprintf (stderr, " -t targetdn\tdn to change password\n");
@ -362,6 +363,7 @@ main (int argc, char *argv[])
int scope = LDAP_SCOPE_SUBTREE;
int sizelimit = LDAP_NO_LIMIT;
int timelimit = LDAP_NO_LIMIT;
int version = LDAP_VERSION2;
int want_bindpw = 0;
int want_newpw = 0;
LDAP *ld;
@ -373,7 +375,7 @@ main (int argc, char *argv[])
if (argc == 1)
usage (argv[0]);
while ((i = getopt (argc, argv, "a:b:C:D:d:Ee:g:H:h:Kkl:np:s:t:vWw:Y:y:z:")) != EOF)
while ((i = getopt (argc, argv, "a:b:C:D:d:Ee:g:H:h:Kkl:nP:p:s:t:vWw:Y:y:z:")) != EOF)
{
switch (i)
{
@ -454,6 +456,18 @@ main (int argc, char *argv[])
noupdates++;
break;
case 'P':
switch(optarg[0])
{
case '2':
version = LDAP_VERSION2;
break;
case '3':
version = LDAP_VERSION3;
break;
}
break;
case 'p': /* ldap port */
ldapport = strtol (optarg, NULL, 10);
break;
@ -554,6 +568,7 @@ main (int argc, char *argv[])
ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
}
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
/* authenticate to server */
if (ldap_bind_s (ld, binddn, bindpw, authmethod) != LDAP_SUCCESS)

View file

@ -49,6 +49,7 @@ usage( char *s )
#endif
fprintf( stderr, " -h host\tldap server\n" );
fprintf( stderr, " -p port\tport on ldap server\n" );
fprintf( stderr, " -P version\tprocotol version (2 or 3)\n" );
exit( 1 );
}
@ -88,7 +89,7 @@ main( int argc, char **argv )
FILE *fp;
int rc, i, first, scope, deref, attrsonly;
int referrals, timelimit, sizelimit, debug;
int authmethod, want_bindpw;
int authmethod, version, want_bindpw;
LDAP *ld;
infile = NULL;
@ -98,8 +99,9 @@ main( int argc, char **argv )
sizelimit = timelimit = debug = 0;
scope = LDAP_SCOPE_SUBTREE;
authmethod = LDAP_AUTH_SIMPLE;
version = LDAP_VERSION2;
while (( i = getopt( argc, argv, "WKknuvtRABLD: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:p:F:a:w:l:z:S:")) != EOF ) {
switch( i ) {
case 'n': /* do Not do any searches */
++not;
@ -203,6 +205,17 @@ main( int argc, char **argv )
case 'W':
want_bindpw++;
break;
case 'P':
switch(optarg[0])
{
case '2':
version = LDAP_VERSION2;
break;
case '3':
version = LDAP_VERSION3;
break;
}
break;
default:
usage( argv[0] );
}
@ -268,6 +281,10 @@ main( int argc, char **argv )
/* set option error */
}
if (ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) == -1) {
/* set option error */
}
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");

View file

@ -26,6 +26,8 @@ ldapdelete \- ldap delete entry tool
[\c
.BI \-h \ ldaphost\fR]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-p \ ldapport\fR]
[\c
.IR dn ]...
@ -96,6 +98,9 @@ Specify an alternate host on which the ldap server is running.
.TP
.BI \-p \ ldapport
Specify an alternate TCP port where the ldap server is listening.
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.SH EXAMPLE
The following command:
.LP

View file

@ -30,6 +30,8 @@ ldapmodify, ldapadd \- ldap modify entry and ldap add entry tools
[\c
.BI \-p \ ldapport\fR]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-f \ file\fR]
.LP
.B ldapadd
@ -147,6 +149,9 @@ Specify an alternate host on which the ldap server is running.
.TP
.BI \-p \ ldapport
Specify an alternate TCP port where the ldap server is listening.
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.SH INPUT FORMAT
The contents of \fIfile\fP (or standard input if no \-f flag is given on
the command line) should conform to the format defined in

View file

@ -28,6 +28,8 @@ ldapmodrdn \- ldap modify entry RDN tool
[\c
.BI \-p \ ldapport\fR]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-f \ file\fR]
[\c
.I dn rdn\fR]
@ -98,6 +100,9 @@ Specify an alternate host on which the ldap server is running.
.TP
.B \-p ldapport
Specify an alternate TCP port where the ldap server is listening.
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.SH INPUT FORMAT
If the command-line arguments \fIdn\fP and \fIrdn\fP are given, \fIrdn\fP
will replace the RDN of the entry specified by the DN, \fIdn\fP.

View file

@ -30,6 +30,8 @@ ldappasswd \- change the password of an LDAP entry
[\c
.BR \-n ]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-p \ ldapport\fR]
[\c
.BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
@ -115,6 +117,9 @@ Make no modifications. (Can be useful when used in conjunction with
.BR \-v \ or
.BR \-d )
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.TP
.BI \-p \ ldapport
Specify an alternate port on which the ldap server is running.
.TP

View file

@ -40,6 +40,8 @@ ldapsearch \- ldap search tool
[\c
.BI \-p \ ldapport\fR]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-b \ searchbase\fR]
[\c
.BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
@ -189,6 +191,9 @@ to specify that aliases are never dereferenced, always dereferenced,
dereferenced when searching, or dereferenced only when locating the
base object for the search. The default is to never dereference aliases.
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.TP
.BI \-l \ timelimit
wait at most \fItimelimit\fP seconds for a search to complete.
.TP