1 /* attribute.c - ldbm backend acl attribute routine */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
17 #include "proto-back-ldbm.h"
20 /* return 0 IFF we can retrieve the attributes
30 AttributeDescription *entry_at,
34 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
40 const char *entry_at_name = entry_at->ad_cname->bv_val;
42 Debug( LDAP_DEBUG_ARGS,
43 "=> ldbm_back_attribute: gr dn: \"%s\"\n",
45 Debug( LDAP_DEBUG_ARGS,
46 "=> ldbm_back_attribute: at: \"%s\"\n",
47 entry_at_name, 0, 0 );
49 Debug( LDAP_DEBUG_ARGS,
50 "=> ldbm_back_attribute: tr dn: \"%s\"\n",
51 target ? target->e_ndn : "", 0, 0 );
53 if (target != NULL && strcmp(target->e_ndn, e_ndn) == 0) {
54 /* we already have a LOCKED copy of the entry */
56 Debug( LDAP_DEBUG_ARGS,
57 "=> ldbm_back_attribute: target is entry: \"%s\"\n",
61 /* can we find entry with reader lock */
62 if ((e = dn2entry_r(be, e_ndn, NULL )) == NULL) {
63 Debug( LDAP_DEBUG_ACL,
64 "=> ldbm_back_attribute: cannot find entry: \"%s\"\n",
69 Debug( LDAP_DEBUG_ACL,
70 "=> ldbm_back_attribute: found entry: \"%s\"\n",
76 /* find attribute values
79 if( is_entry_alias( e ) ) {
80 Debug( LDAP_DEBUG_ACL,
81 "<= ldbm_back_attribute: entry is an alias\n", 0, 0, 0 );
85 if( is_entry_referral( e ) ) {
86 Debug( LDAP_DEBUG_ACL,
87 "<= ldbm_back_attribute: entry is an referral\n", 0, 0, 0 );
91 if (conn != NULL && op != NULL
92 && access_allowed(be, conn, op, e, slap_schema.si_ad_entry, NULL, ACL_SEARCH) == 0)
97 if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) {
98 Debug( LDAP_DEBUG_ACL,
99 "<= ldbm_back_attribute: failed to find %s\n",
100 entry_at_name, 0, 0 );
104 if (conn != NULL && op != NULL
105 && access_allowed(be, conn, op, e, entry_at, NULL, ACL_SEARCH) == 0)
110 for ( i = 0; attr->a_vals[i] != NULL; i++ ) { }
111 v = (char **) ch_calloc( (i + 1), sizeof(char *) );
113 for ( j = 0, abv = attr->a_vals; --i >= 0; abv++ ) {
114 if ( (*abv)->bv_len > 0 ) {
115 s = ch_malloc( (*abv)->bv_len + 1 );
118 memcpy(s, (*abv)->bv_val, (*abv)->bv_len);
119 s[(*abv)->bv_len] = 0;
131 /* free entry and reader lock */
132 cache_return_entry_r( &li->li_cache, e );
135 Debug( LDAP_DEBUG_TRACE, "ldbm_back_attribute: rc=%d\n", rc, 0, 0 );