#ifdef LDAP_CONTROL_X_DIRSYNC
static int print_dirsync( LDAP *ld, LDAPControl *ctrl );
#endif
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+static int print_account_usability( LDAP *ld, LDAPControl *ctrl );
+#endif
static struct tool_ctrls_t {
const char *oid;
{ LDAP_CONTROL_SYNC_DONE, TOOL_SEARCH, print_syncdone },
#ifdef LDAP_CONTROL_X_DIRSYNC
{ LDAP_CONTROL_X_DIRSYNC, TOOL_SEARCH, print_dirsync },
+#endif
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+ { LDAP_CONTROL_X_ACCOUNT_USABILITY, TOOL_SEARCH, print_account_usability },
#endif
{ NULL, 0, NULL }
};
}
#endif
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+static int
+print_account_usability( LDAP *ld, LDAPControl *ctrl )
+{
+ LDAPAccountUsability usability;
+ ber_int_t available = 0;
+ int rc;
+
+ rc = ldap_parse_accountusability_control( ld, ctrl, &available, &usability );
+ if ( rc == LDAP_SUCCESS ) {
+ char buf[ BUFSIZ ], *ptr = buf;
+
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "%savailable", available ? "" : "not " );
+ if ( available ) {
+ if ( usability.seconds_remaining == -1 ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ " and does not expire" );
+ } else {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ " expire=%d", usability.seconds_remaining );
+ }
+ } else {
+ int added = 0;
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ " (" /* ')' */ );
+
+ if ( usability.more_info.inactive ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "inactive " );
+ added++;
+ }
+ if ( usability.more_info.reset ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "reset " );
+ added++;
+ }
+ if ( usability.more_info.expired ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "expired " );
+ added++;
+ }
+
+ if ( added ) {
+ ptr[-1] = ')';
+ *ptr++ = ' ';
+ } else {
+ *(--ptr) = '\0';
+ }
+
+ if ( usability.more_info.remaining_grace != -1 ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "grace=%d ", usability.more_info.remaining_grace );
+ }
+
+ if ( usability.more_info.seconds_before_unlock != -1 ) {
+ ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+ "seconds_before_unlock=%d ", usability.more_info.seconds_before_unlock );
+ }
+
+ *(--ptr) = '\0';
+ }
+
+ tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
+ ldif ? "accountUsability: " : "accountUsability", buf, ptr - buf );
+ }
+
+ return rc;
+}
+#endif
+
void tool_print_ctrls(
LDAP *ld,
LDAPControl **ctrls )
fprintf( stderr, _(" -b basedn base dn for search\n"));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -E [!]<ext>[=<extparam>] search extensions (! indicates criticality)\n"));
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+ fprintf( stderr, _(" [!]accountUsability (NetScape Account usability)\n"));
+#endif
fprintf( stderr, _(" [!]domainScope (domain scope)\n"));
fprintf( stderr, _(" !dontUseCopy (Don't Use Copy)\n"));
fprintf( stderr, _(" [!]mv=<filter> (RFC 3876 matched values filter)\n"));
static int subentries = 0, valuesReturnFilter = 0;
static char *vrFilter = NULL;
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+static int accountUsability = 0;
+#endif
+
#ifdef LDAP_CONTROL_DONTUSECOPY
static int dontUseCopy = 0;
#endif
serverNotif = 1 + crit;
#endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+ } else if ( strcasecmp( control, "accountUsability" ) == 0 ) {
+ if( accountUsability ) {
+ fprintf( stderr,
+ _("accountUsability control previously specified\n"));
+ exit( EXIT_FAILURE );
+ }
+ if( cvalue != NULL ) {
+ fprintf( stderr,
+ _("accountUsability: no control value expected\n") );
+ usage();
+ }
+
+ accountUsability = 1 + crit;
+#endif /* LDAP_CONTROL_X_ACCOUNT_USABILITY */
+
} else if ( tool_is_oid( control ) ) {
if ( c != NULL ) {
int i;
save_nctrls = nctrls;
i = nctrls;
if ( nctrls > 0
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+ || accountUsability
+#endif
#ifdef LDAP_CONTROL_DONTUSECOPY
|| dontUseCopy
#endif
|| vlv )
{
+#ifdef LDAP_CONTROL_X_ACCOUNT_USABILITY
+ if ( accountUsability ) {
+ if ( ctrl_add() ) {
+ tool_exit( ld, EXIT_FAILURE );
+ }
+
+ c[i].ldctl_oid = LDAP_CONTROL_X_ACCOUNT_USABILITY;
+ c[i].ldctl_value.bv_val = NULL;
+ c[i].ldctl_value.bv_len = 0;
+ c[i].ldctl_iscritical = accountUsability == 2;
+ i++;
+ }
+#endif
+
#ifdef LDAP_CONTROL_DONTUSECOPY
if ( dontUseCopy ) {
if ( ctrl_add() ) {