1 /* ava.c - routines for dealing with attribute value assertions */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
32 #include <ac/socket.h>
40 AttributeAssertion *ava,
44 op->o_tmpfree( ava->aa_value.bv_val, op->o_tmpmemctx );
46 op->o_tmpfree( (char *) ava, op->o_tmpmemctx );
54 AttributeAssertion **ava,
60 struct berval type, value;
61 AttributeAssertion *aa;
63 rtag = ber_scanf( ber, "{mm}", &type, &value );
65 if( rtag == LBER_ERROR ) {
67 LDAP_LOG( FILTER, ERR, "get_ava: ber_scanf failure\n", 0, 0, 0 );
69 Debug( LDAP_DEBUG_ANY, " get_ava ber_scanf\n", 0, 0, 0 );
71 *text = "Error decoding attribute value assertion";
72 return SLAPD_DISCONNECT;
75 aa = op->o_tmpalloc( sizeof( AttributeAssertion ), op->o_tmpmemctx );
77 aa->aa_value.bv_val = NULL;
79 rc = slap_bv2ad( &type, &aa->aa_desc, text );
81 if( rc != LDAP_SUCCESS ) {
83 LDAP_LOG( FILTER, ERR,
84 "get_ava: unknown attributeType %s\n", type.bv_val, 0, 0 );
86 Debug( LDAP_DEBUG_FILTER,
87 "get_ava: unknown attributeType %s\n", type.bv_val, 0, 0 );
89 op->o_tmpfree( aa, op->o_tmpmemctx );
93 rc = asserted_value_validate_normalize(
94 aa->aa_desc, ad_mr(aa->aa_desc, usage),
95 usage, &value, &aa->aa_value, text, op->o_tmpmemctx );
97 if( rc != LDAP_SUCCESS ) {
99 LDAP_LOG( FILTER, ERR,
100 "get_ava: illegal value for attributeType %s\n", type.bv_val, 0, 0 );
102 Debug( LDAP_DEBUG_FILTER,
103 "get_ava: illegal value for attributeType %s\n", type.bv_val, 0, 0 );
105 op->o_tmpfree( aa, op->o_tmpmemctx );