- char buf[ 4096 ];
- FILE *fp;
- int i, rc, authmethod, referrals, want_bindpw, version, debug, manageDSAit;
-
- not = verbose = contoper = want_bindpw = debug = manageDSAit = referrals = 0;
- fp = NULL;
- authmethod = LDAP_AUTH_SIMPLE;
- version = -1;
-
- while (( i = getopt( argc, argv, "cCD:d:Ef:h:IKMnP:p:rU:vWw:X:Y:Z" )) != EOF ) {
- switch( i ) {
- case 'k': /* kerberos bind */
-#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] );
- return( EXIT_FAILURE );
-#endif
- break;
- case 'K': /* kerberos bind, part one only */
-#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] );
- return( EXIT_FAILURE );
-#endif
- break;
- case 'c': /* continuous operation mode */
- ++contoper;
- break;
- case 'C':
- referrals++;
- break;
- case 'h': /* ldap host */
- ldaphost = strdup( optarg );
- break;
- case 'D': /* bind DN */
- binddn = strdup( optarg );
- break;
- case 'w': /* password */
- passwd.bv_val = strdup( optarg );
- {
- char* p;
-
- for( p = optarg; *p == '\0'; p++ ) {
- *p = '*';
- }
- }
- passwd.bv_len = strlen( passwd.bv_val );
- break;
- case 'f': /* read DNs from a file */
- if (( fp = fopen( optarg, "r" )) == NULL ) {
- perror( optarg );
- exit( EXIT_FAILURE );
- }
- break;
- case 'd':
- debug |= atoi( optarg );
- break;
- case 'p':
- ldapport = atoi( optarg );
- break;
- case 'n': /* print deletes, don't actually do them */
- ++not;
- break;
- case 'r':
- prune = 1;
- break;
- case 'v': /* verbose mode */
- verbose++;
- break;
- case 'M':
- /* enable Manage DSA IT */
- manageDSAit++;
- break;
- case 'W':
- want_bindpw++;
- break;
- case 'P':
- switch( atoi(optarg) )
- {
- case 2:
- version = LDAP_VERSION2;
- break;
- case 3:
- version = LDAP_VERSION3;
- break;
- default:
- fprintf( stderr, "protocol version should be 2 or 3\n" );
- usage( argv[0] );
- return( EXIT_FAILURE );