Commit d8090dea authored by Dave Storey's avatar Dave Storey
Browse files

Streamlined Kerberos Code.

parent 2cd2afb6
......@@ -33,18 +33,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;
......@@ -103,13 +112,6 @@ main( int argc, char **argv )
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
}
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 );
......
......@@ -68,7 +68,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 ) {
......@@ -79,7 +79,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 ) {
......@@ -96,10 +97,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;
......@@ -163,13 +172,6 @@ main( int argc, char **argv )
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
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 );
......
......@@ -35,20 +35,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;
......@@ -124,13 +133,6 @@ main(int argc, char **argv)
/* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
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 );
......
......@@ -85,24 +85,19 @@ 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 referrals, timelimit, sizelimit, authmethod;
LDAP *ld;
infile = NULL;
deref = verbose = allow_binary = not = kerberos = vals2tmp =
deref = verbose = allow_binary = not = vals2tmp =
attrsonly = ldif = 0;
referrals = (int) LDAP_OPT_ON;
sizelimit = timelimit = 0;
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;
......@@ -117,14 +112,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;
......@@ -260,13 +261,6 @@ main( int argc, char **argv )
/* set option error */
}
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 );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment