]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapmodify.c
#define LDAP_LDIF to default to LDIF output
[openldap] / clients / tools / ldapmodify.c
index 043d3bbc3dafd888a528f3932e88298c0c25daae..b6286a1ca6b735680383842ee071d55887ea270a 100644 (file)
@@ -138,7 +138,7 @@ main( int argc, char **argv )
            replace = 1;
            break;
        case 'k':       /* kerberos bind */
-#ifdef HAVE_KERBEROS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
                authmethod = LDAP_AUTH_KRBV4;
 #else
                fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
@@ -147,7 +147,7 @@ main( int argc, char **argv )
 #endif
            break;
        case 'K':       /* kerberos bind, part 1 only */
-#ifdef HAVE_KERBEROS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
                authmethod = LDAP_AUTH_KRBV41;
 #else
                fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
@@ -218,6 +218,22 @@ main( int argc, char **argv )
     if ( argc != optind )
        usage( prog );
 
+       if( authmethod != LDAP_AUTH_SIMPLE ) {
+               if( version == LDAP_VERSION3 ) {
+                       fprintf(stderr, "Kerberos requires LDAPv2\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION2;
+       }
+
+       if( manageDSAit ) {
+               if( version == LDAP_VERSION2 ) {
+                       fprintf(stderr, "manage DSA control requires LDAPv3\n");
+                       return EXIT_FAILURE;
+               }
+               version = LDAP_VERSION3;
+       }
+
     if ( infile != NULL ) {
        if (( fp = fopen( infile, "r" )) == NULL ) {
            perror( infile );
@@ -255,15 +271,15 @@ main( int argc, char **argv )
        /* don't chase referrals */
        ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );
 
-       if (want_bindpw)
-               passwd = getpass("Enter LDAP Password: ");
-
        if (version != -1 &&
                ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS)
        {
                fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION to %d\n", version );
        }
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
        if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
            ldap_perror( ld, "ldap_bind" );
            return( EXIT_FAILURE );