1 /* group.c - ldbm backend acl group 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 op_dn is a value in member attribute
21 * of entry with gr_dn AND that entry has an objectClass
22 * value of groupOfNames
30 ObjectClass *group_oc,
31 AttributeDescription *group_at
34 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
40 AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
41 const char *group_oc_name = NULL;
42 const char *group_at_name = group_at->ad_cname->bv_val;
44 if( group_oc->soc_names && group_oc->soc_names[0] ) {
45 group_oc_name = group_oc->soc_names[0];
47 group_oc_name = group_oc->soc_oid;
50 Debug( LDAP_DEBUG_ARGS,
51 "=> ldbm_back_group: gr dn: \"%s\"\n",
53 Debug( LDAP_DEBUG_ARGS,
54 "=> ldbm_back_group: op dn: \"%s\"\n",
56 Debug( LDAP_DEBUG_ARGS,
57 "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n",
58 group_oc_name, group_at_name, 0 );
60 Debug( LDAP_DEBUG_ARGS,
61 "=> ldbm_back_group: tr dn: \"%s\"\n",
62 target->e_ndn, 0, 0 );
64 if (strcmp(target->e_ndn, gr_ndn) == 0) {
65 /* we already have a LOCKED copy of the entry */
67 Debug( LDAP_DEBUG_ARGS,
68 "=> ldbm_back_group: target is group: \"%s\"\n",
72 /* can we find group entry with reader lock */
73 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
74 Debug( LDAP_DEBUG_ACL,
75 "=> ldbm_back_group: cannot find group: \"%s\"\n",
80 Debug( LDAP_DEBUG_ACL,
81 "=> ldbm_back_group: found group: \"%s\"\n",
85 /* find it's objectClass and member attribute values
86 * make sure this is a group entry
87 * finally test if we can find op_dn in the member attribute value list *
93 if( is_entry_alias( e ) ) {
94 Debug( LDAP_DEBUG_ACL,
95 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
99 if( is_entry_referral( e ) ) {
100 Debug( LDAP_DEBUG_ACL,
101 "<= ldbm_back_group: group is an referral\n", 0, 0, 0 );
105 if( !is_entry_objectclass( e, group_oc ) ) {
106 Debug( LDAP_DEBUG_ACL,
107 "<= ldbm_back_group: failed to find %s in objectClass\n",
108 group_oc_name, 0, 0 );
112 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
113 Debug( LDAP_DEBUG_ACL,
114 "<= ldbm_back_group: failed to find %s\n",
115 group_at_name, 0, 0 );
119 Debug( LDAP_DEBUG_ACL,
120 "<= ldbm_back_group: found objectClass %s and %s\n",
121 group_oc_name, group_at_name, 0 );
123 bv.bv_val = (char *) op_ndn;
124 bv.bv_len = strlen( op_ndn );
126 if( value_find( group_at, attr->a_vals, &bv ) == 0 ) {
127 Debug( LDAP_DEBUG_ACL,
128 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
129 op_ndn, gr_ndn, group_at_name );
135 Debug( LDAP_DEBUG_ACL,
136 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
137 op_ndn, gr_ndn, group_at_name );
143 /* free entry and reader lock */
144 cache_return_entry_r( &li->li_cache, e );
147 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );