struct berval passwd = { 0, NULL };
char *pw_file = NULL;
int referrals = 0;
+int protocol = -1;
int verbose = 0;
-int version = -1;
-
+int version = 0;
/* Set in main() */
-char *prog;
+char *prog = NULL;
+char *version_string = NULL;
void
" -R realm SASL realm\n",
" -U authcid SASL authentication identity\n",
" -v run in verbose mode (diagnostics to standard output)\n",
+" -V print version info (-VV only)\n",
" -w passwd bind passwd (for simple authentication)\n",
" -W prompt for bind passwd\n",
" -x Simple authentication\n",
" -Z Start TLS request (-ZZ to require successful response)\n",
NULL
};
- const char *const *cpp, *cp;
+ const char *const *cpp;
fputs( "Common options:\n", stderr );
- for( cpp = descriptions; (cp = *cpp) != NULL; cpp++ )
- if( strchr( options, cp[3] ) )
- fputs( cp, stderr );
+ for( cpp = descriptions; *cpp != NULL; cpp++ ) {
+ if( strchr( options, (*cpp)[3] ) ) {
+ fputs( *cpp, stderr );
+ }
+ }
}
case 'P':
switch( atoi(optarg) ) {
case 2:
- if( version == LDAP_VERSION3 ) {
+ if( protocol == LDAP_VERSION3 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
- version = LDAP_VERSION2;
+ protocol = LDAP_VERSION2;
break;
case 3:
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
- version = LDAP_VERSION3;
+ protocol = LDAP_VERSION3;
break;
default:
fprintf( stderr, "%s: protocol version should be 2 or 3\n",
case 'v': /* verbose mode */
verbose = 1;
break;
+ case 'V': /* version */
+ version++;
+ break;
case 'w': /* password */
passwd.bv_val = ber_strdup( optarg );
{
}
}
- if (version == -1)
- version = LDAP_VERSION3;
+ if (version) {
+ fprintf( stderr, "%s: %s\n", prog,
+ version_string ? version_string : "version unknown" );
+ if (version > 1) exit( EXIT_SUCCESS );
+ }
+
+ if (protocol == -1)
+ protocol = LDAP_VERSION3;
- if (authmethod == -1 && version > LDAP_VERSION2) {
+ if (authmethod == -1 && protocol > LDAP_VERSION2) {
#ifdef HAVE_CYRUS_SASL
authmethod = LDAP_AUTH_SASL;
#else
exit( EXIT_FAILURE );
}
}
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
if( authzid || manageDSAit || noop ) {
fprintf( stderr, "%s: -e/-M incompatible with LDAPv2\n", prog );
exit( EXIT_FAILURE );
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if ( authmethod = LDAP_AUTH_KRBV4 || authmethod == LDAP_AUTH_KRBV41 ) {
fprintf( stderr, "%s: -k/-K incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
#endif
exit( EXIT_FAILURE );
}
- if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version )
+ if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
- version );
+ protocol );
exit( EXIT_FAILURE );
}
#ifndef _COMMON_H_
#define _COMMON_H_
+LDAP_BEGIN_DECL
+
/* Defined and set in common.c */
extern int authmethod;
extern char *binddn;
extern struct berval passwd;
extern char *pw_file;
extern int referrals;
+extern int protocol;
extern int verbose;
extern int version;
/* Defined in common.c, set in main() */
-char *prog;
+extern char *prog;
/* Defined in main program */
extern const char options[];
void tool_bind LDAP_P(( LDAP * ));
void tool_server_controls LDAP_P(( LDAP *, LDAPControl *, int ));
+LDAP_END_DECL
+
#endif /* _COMMON_H_ */
LDAPControl **cctrls));
-const char options[] = "z" "Cd:D:e:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z";
+const char options[] = "z"
+ "Cd:D:e:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
char *control, *cvalue;
int crit;
case 'E': /* compare controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
# Name "ldapcompare - Win32 Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapcompare.c
# End Source File
# End Target
}
-const char options[] = "r" "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z";
+const char options[] = "r"
+ "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
int crit;
char *control, *cvalue;
case 'E': /* delete controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
# Name "ldapdelete - Win32 Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapdelete.c
# End Source File
# End Target
}
-const char options[] = "aFrS:" "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z";
+const char options[] = "aFrS:"
+ "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
char *control, *cvalue;
int crit;
case 'E': /* modify controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
# Name "ldapmodify - Win32 Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapmodify.c
# End Source File
# End Target
}
-const char options[] = "rs:" "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z";
+const char options[] = "rs:"
+ "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
int crit;
char *control, *cvalue;
case 'E': /* modrdn controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
prog, version );
exit( EXIT_FAILURE );
break;
case 's': /* newSuperior */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -X incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
newSuperior = strdup( optarg );
- version = LDAP_VERSION3;
+ protocol = LDAP_VERSION3;
break;
default:
# Name "ldapmodrdn - Win32 Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapmodrdn.c
# End Source File
# End Target
}
-const char options[] = "a:As:S" "Cd:D:e:h:H:InO:p:QR:U:vw:WxX:Y:Z";
+const char options[] = "a:As:S"
+ "Cd:D:e:h:H:InO:p:QR:U:vVw:WxX:Y:Z";
int
handle_private_option( int i )
int crit;
char *control, *cvalue;
case 'E': /* passwd controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
prog = lutil_progname( "ldappasswd", argc, argv );
/* LDAPv3 only */
- version = LDAP_VERSION3;
+ protocol = LDAP_VERSION3;
tool_args( argc, argv );
# Name "ldappasswd - Win32 Single Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldappasswd.c
# End Source File
# End Target
const char options[] = "a:Ab:E:F:l:Ls:S:tT:uz:"
- "Cd:D:e:f:h:H:IkKMnO:p:P:QR:U:vw:WxX:y:Y:Z";
+ "Cd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
base = strdup( optarg );
break;
case 'E': /* search controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
}
vrFilter = cvalue;
- version = LDAP_VERSION3;
+ protocol = LDAP_VERSION3;
} else if ( strcasecmp( control, "pr" ) == 0 ) {
int num, tmp;
"# base <%s> with scope %s\n"
"# filter%s: %s\n"
"# requesting: ",
- version,
+ protocol,
base ? base : "", (scope == LDAP_SCOPE_BASE) ? "base"
: ((scope == LDAP_SCOPE_ONELEVEL) ? "one" : "sub"),
infile != NULL ? " pattern" : "",
# Name "ldapsearch - Win32 Debug"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapsearch.c
# End Source File
# End Target
}
-const char options[] = "Cd:D:e:h:H:InO:p:QR:U:vw:WxX:y:Y:Z";
+const char options[] = ""
+ "Cd:D:e:h:H:InO:p:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
char *control, *cvalue;
int crit;
case 'E': /* whoami controls */
- if( version == LDAP_VERSION2 ) {
+ if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -E incompatible with LDAPv%d\n",
- prog, version );
+ prog, protocol );
exit( EXIT_FAILURE );
}
prog = lutil_progname( "ldapwhoami", argc, argv );
/* LDAPv3 only */
- version = LDAP_VERSION3;
+ protocol = LDAP_VERSION3;
tool_args( argc, argv );
# Name "ldapwhoami - Win32 Single Release"
# Begin Source File
+SOURCE=.\common.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ldapwhoami.c
# End Source File
# End Target