]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapmodrdn.c
Rework saslRegex code (not yet tested)
[openldap] / clients / tools / ldapmodrdn.c
index 3ab276dc33608a2063ab46269ba9b2ba8baec8ed..b5d2d5928388694bc56d83837f6c464dc4dc7cb1 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP.
@@ -29,6 +29,7 @@
 #include <ac/unistd.h>
 
 #include <ldap.h>
+#include "lutil.h"
 #include "lutil_ldap.h"
 #include "ldap_defaults.h"
 
@@ -82,18 +83,18 @@ usage( const char *s )
 "  -k         use Kerberos authentication\n"
 "  -K         like -k, but do only step 1 of the Kerberos bind\n"
 "  -M         enable Manage DSA IT control (-MM to make critical)\n"
-"  -n         show what would be done but don't actually search\n"
+"  -n         show what would be done but don't actually update\n"
 "  -O props   SASL security properties\n"
 "  -p port    port on LDAP server\n"
 "  -P version procotol version (default: 3)\n"
 "  -Q         use SASL Quiet mode\n"
 "  -R realm   SASL realm\n"
-"  -U user    SASL authentication identity (username)\n"
+"  -U authzid SASL authentication identity\n"
 "  -v         run in verbose mode (diagnostics to standard output)\n"
 "  -w passwd  bind passwd (for simple authentication)\n"
 "  -W         prompt for bind passwd\n"
 "  -x         Simple authentication\n"
-"  -X id      SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"
+"  -X authzid SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"
 "  -Y mech    SASL mechanism\n"
 "  -Z         Start TLS request (-ZZ to require successful response)\n"
 ,              s );
@@ -116,7 +117,7 @@ main(int argc, char **argv)
     authmethod = -1;
        version = -1;
 
-    prog = (prog = strrchr(argv[0], *LDAP_DIRSEP)) == NULL ? argv[0] : prog + 1;
+    prog = lutil_progname( "ldapmodrdn", argc, argv );
 
     while (( i = getopt( argc, argv, "cf:rs:"
                "Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:Y:Z" )) != EOF )
@@ -482,7 +483,7 @@ main(int argc, char **argv)
        default:
                fprintf( stderr, "%s: unrecognized option -%c\n",
                        prog, optopt );
-           usage( argv[0] );
+           usage( prog );
            return( EXIT_FAILURE );
        }
     }
@@ -512,7 +513,7 @@ main(int argc, char **argv)
     } else if ( argc - optind != 0 ) {
        fprintf( stderr, "%s: invalid number of arguments (%d), "
                "only two allowed\n", prog, argc-optind );
-       usage( argv[0] );
+       usage( prog );
        return( EXIT_FAILURE );
     }
 
@@ -547,7 +548,7 @@ main(int argc, char **argv)
 
                ld = ldap_init( ldaphost, ldapport );
                if( ld == NULL ) {
-                       perror("ldapsearch: ldap_init");
+                       perror("ldapmodify: ldap_init");
                        return EXIT_FAILURE;
                }
 
@@ -582,12 +583,11 @@ main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       if ( use_tls && ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
+       if ( use_tls && ( ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS )) {
+               ldap_perror( ld, "ldap_start_tls" );
                if ( use_tls > 1 ) {
-                       ldap_perror( ld, "ldap_start_tls" );
                        return( EXIT_FAILURE );
                }
-               fprintf( stderr, "WARNING: could not start TLS\n" );
        }
 
        if (want_bindpw) {
@@ -628,7 +628,7 @@ main(int argc, char **argv)
                }
 #else
                fprintf( stderr, "%s: not compiled with SASL support\n",
-                       argv[0] );
+                       prog );
                return( EXIT_FAILURE );
 #endif
        }