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
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 );
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 );
{
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 ];
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 ) {
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 );
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 );
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
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 );
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 );
#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");
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;
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)
{
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;
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)
#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 );
}
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;
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;
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] );
}
/* 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: ");
[\c
.BI \-h \ ldaphost\fR]
[\c
+.BI \-P \ 2\fR\||\|\fI3\fR]
+[\c
.BI \-p \ ldapport\fR]
[\c
.IR dn ]...
.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
[\c
.BI \-p \ ldapport\fR]
[\c
+.BI \-P \ 2\fR\||\|\fI3\fR]
+[\c
.BI \-f \ file\fR]
.LP
.B ldapadd
.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
[\c
.BI \-p \ ldapport\fR]
[\c
+.BI \-P \ 2\fR\||\|\fI3\fR]
+[\c
.BI \-f \ file\fR]
[\c
.I dn rdn\fR]
.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.
[\c
.BR \-n ]
[\c
+.BI \-P \ 2\fR\||\|\fI3\fR]
+[\c
.BI \-p \ ldapport\fR]
[\c
.BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
.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
[\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]
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