Beispiel #1
0
/*
   Checks whether an entry has a particular attribute type, and optionally
   returns the value.  Only for use with single-valued attributes - it returns
   the first value it finds.
*/
int
has_attr( Slapi_Entry* target_entry, char* attr_name, char** val ) {
    Slapi_ValueSet *values = NULL;
    Slapi_Value* sval;
    char *actual_type_name = NULL;
    int type_name_disposition = 0, attr_free_flags = 0, rc = 0;

    /* Use vattr interface to support virtual attributes, e.g.
       acctPolicySubentry has a good chance of being supplied by CoS */
    if ( slapi_vattr_values_get( target_entry, attr_name, &values, &type_name_disposition, &actual_type_name, 0, &attr_free_flags) == 0) {
        if( slapi_valueset_first_value( values, &sval ) == -1 ) {
            rc = 0;
        } else {
            rc = 1;
            if( val ) {
                /* Caller wants a copy of the found attribute's value */
                *val = slapi_ch_strdup( slapi_value_get_string( sval ) );
            }
        }
    } else {
        rc = 0;
    }

    slapi_vattr_values_free(&values, &actual_type_name, attr_free_flags);
    return( rc );
}
Beispiel #2
0
static void pwd_values_free(Slapi_ValueSet** results,
                            char** actual_type_name, int buffer_flags)
{
    slapi_vattr_values_free(results, actual_type_name, buffer_flags);
}