static char *urlpre = NULL;
static char *binddn = NULL;
-static char *passwd = NULL;
+static struct berval passwd = { 0, NULL };
static char *base = NULL;
static char *ldaphost = NULL;
static int ldapport = 0;
ldapport = atoi( optarg );
break;
case 'w': /* bind password */
- passwd = strdup( optarg );
+ passwd.bv_val = strdup( optarg );
{
char* p;
*p = '*';
}
}
+ passwd.bv_len = strlen( passwd.bv_val );
break;
case 'l': /* time limit */
timelimit = atoi( optarg );
}
if (want_bindpw) {
- passwd = getpass("Enter LDAP Password: ");
+ passwd.bv_val = getpass("Enter LDAP Password: ");
+ passwd.bv_len = strlen( passwd.bv_val );
}
if ( authmethod == LDAP_AUTH_SASL ) {
return( EXIT_FAILURE );
}
- if ( ldap_negotiated_sasl_bind_s( ld, binddn, sasl_authc_id,
- sasl_authz_id, sasl_mech, NULL, NULL, NULL )
- != LDAP_SUCCESS ) {
+ rc = ldap_negotiated_sasl_bind_s( ld, binddn, sasl_authc_id,
+ sasl_authz_id, sasl_mech,
+ passwd.bv_len ? &passwd : NULL,
+ NULL, NULL );
+
+ if( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_negotiated_sasl_bind_s" );
return( EXIT_FAILURE );
}
#endif
}
else {
- if ( ldap_bind_s( ld, binddn, passwd, authmethod )
+ if ( ldap_bind_s( ld, binddn, passwd.bv_val, authmethod )
!= LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
return( EXIT_FAILURE );