]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Import improved handling of kerberos bind option.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 20 Jan 1999 00:28:52 +0000 (00:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 20 Jan 1999 00:28:52 +0000 (00:28 +0000)
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c

index e1cae1b82f4f8debed2d8ab462da14c81cb0307f..9ac662fd123c751516d798dc254bad0e28234591 100644 (file)
@@ -36,18 +36,27 @@ 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               buf[ 4096 ];
     FILE               *fp;
-    int                        i, rc, kerberos, authmethod;
+    int                        i, rc, authmethod;
 
-    kerberos = not = verbose = contoper = 0;
+    not = verbose = contoper = 0;
     fp = NULL;
+    authmethod = LDAP_AUTH_SIMPLE;
 
     while (( i = getopt( argc, argv, "nvkKch:p:D:w:d:f:" )) != EOF ) {
        switch( i ) {
        case 'k':       /* kerberos bind */
-           kerberos = 2;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV4;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'K':       /* kerberos bind, part one only */
-           kerberos = 1;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV41;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'c':       /* continuous operation mode */
            ++contoper;
@@ -102,13 +111,6 @@ main( int argc, char **argv )
 
     ld->ld_deref = LDAP_DEREF_NEVER;   /* prudent, but probably unnecessary */
 
-    if ( !kerberos ) {
-       authmethod = LDAP_AUTH_SIMPLE;
-    } else if ( kerberos == 1 ) {
-       authmethod = LDAP_AUTH_KRBV41;
-    } else {
-       authmethod = LDAP_AUTH_KRBV4;
-    }
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );
index 01b2cbc85142ec0ace613d6469335d2dc6c389fb..2b3074ccd8038616cb4e6d78654060cfae1a552a 100644 (file)
@@ -71,7 +71,7 @@ main( int argc, char **argv )
 {
     char               *infile, *rbuf, *start, *p, *q;
     FILE               *fp;
-    int                        rc, i, kerberos, use_ldif, authmethod;
+    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";
 
     if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
@@ -82,7 +82,8 @@ main( int argc, char **argv )
     new = ( strcmp( prog, "ldapadd" ) == 0 );
 
     infile = NULL;
-    kerberos = not = verbose = valsfromfiles = 0;
+    not = verbose = valsfromfiles = 0;
+    authmethod = LDAP_AUTH_SIMPLE;
 
     while (( i = getopt( argc, argv, "FabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
        switch( i ) {
@@ -99,10 +100,18 @@ main( int argc, char **argv )
            replace = 1;
            break;
        case 'k':       /* kerberos bind */
-           kerberos = 2;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV4;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'K':       /* kerberos bind, part 1 only */
-           kerberos = 1;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV41;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'F':       /* force all changes records to be used */
            force = 1;
@@ -165,13 +174,6 @@ main( int argc, char **argv )
 
        ld->ld_deref = LDAP_DEREF_NEVER;        /* this seems prudent */
 
-       if ( !kerberos ) {
-           authmethod = LDAP_AUTH_SIMPLE;
-       } else if ( kerberos == 1 ) {
-           authmethod = LDAP_AUTH_KRBV41;
-       } else {
-           authmethod = LDAP_AUTH_KRBV4;
-       }
        if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
            ldap_perror( ld, "ldap_bind" );
            exit( 1 );
index 229468473d2f307296d88063085d9b3a878c5586..332691bdd512aebafa2eda134496aee5e4d07349 100644 (file)
@@ -38,20 +38,29 @@ 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               *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
     FILE               *fp;
-    int                        rc, i, kerberos, remove, havedn, authmethod;
+    int                        rc, i, remove, havedn, authmethod;
 
     infile = NULL;
-    kerberos = not = contoper = verbose = remove = 0;
+    not = contoper = verbose = remove = 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 ) {
        switch( i ) {
        case 'k':       /* kerberos bind */
-           kerberos = 2;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV4;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'K':       /* kerberos bind, part one only */
-           kerberos = 1;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV41;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'c':       /* continuous operation mode */
            ++contoper;
@@ -126,13 +135,6 @@ main(int argc, char **argv)
 
     ld->ld_deref = LDAP_DEREF_NEVER;   /* this seems prudent */
 
-    if ( !kerberos ) {
-       authmethod = LDAP_AUTH_SIMPLE;
-    } else if ( kerberos == 1 ) {
-       authmethod = LDAP_AUTH_KRBV41;
-    } else {
-       authmethod = LDAP_AUTH_KRBV4;
-    }
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );
index 065dc790def37494edbbfa230798e16b3aa47430..a6ab61426de613249ea1ff81ed70110926197d2a 100644 (file)
@@ -89,13 +89,14 @@ main( int argc, char **argv )
 {
     char               *infile, *filtpattern, **attrs, line[ BUFSIZ ];
     FILE               *fp;
-    int                        rc, i, first, scope, kerberos, deref, attrsonly;
+    int                        rc, i, first, scope, deref, attrsonly;
     int                        ldap_options, timelimit, sizelimit, authmethod;
     LDAP               *ld;
 
     infile = NULL;
-    verbose = allow_binary = not = kerberos = vals2tmp =
+    verbose = allow_binary = not = vals2tmp =
            attrsonly = ldif = 0;
+
 #ifdef LDAP_REFERRALS
     ldap_options = LDAP_OPT_REFERRALS;
 #else /* LDAP_REFERRALS */
@@ -104,14 +105,9 @@ main( int argc, char **argv )
 
     deref = sizelimit = timelimit = -1;
        scope = LDAP_SCOPE_SUBTREE;
+    authmethod = LDAP_AUTH_SIMPLE;
 
-    while (( i = getopt( argc, argv,
-#ifdef HAVE_KERBEROS
-           "KknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:"
-#else
-           "nuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:"
-#endif
-           )) != EOF ) {
+    while (( i = getopt( argc, argv, "KknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:")) != EOF ) {
        switch( i ) {
        case 'n':       /* do Not do any searches */
            ++not;
@@ -126,14 +122,20 @@ main( int argc, char **argv )
            fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
 #endif /* LDAP_DEBUG */
            break;
-#ifdef HAVE_KERBEROS
        case 'k':       /* use kerberos bind */
-           kerberos = 2;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV4;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
+#endif
            break;
        case 'K':       /* use kerberos bind, 1st part only */
-           kerberos = 1;
-           break;
+#ifdef HAVE_KERBEROS
+               authmethod = LDAP_AUTH_KRBV41;
+#else
+               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
 #endif
+           break;
        case 'u':       /* include UFN */
            ++includeufn;
            break;
@@ -272,13 +274,6 @@ main( int argc, char **argv )
        }
     ld->ld_options = ldap_options;
 
-    if ( !kerberos ) {
-       authmethod = LDAP_AUTH_SIMPLE;
-    } else if ( kerberos == 1 ) {
-       authmethod = LDAP_AUTH_KRBV41;
-    } else {
-       authmethod =  LDAP_AUTH_KRBV4;
-    }
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );