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
32 ObjectClass *group_oc,
33 AttributeDescription *group_at
36 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
42 const char *group_oc_name = NULL;
43 const char *group_at_name = group_at->ad_cname.bv_val;
45 if( group_oc->soc_names && group_oc->soc_names[0] ) {
46 group_oc_name = group_oc->soc_names[0];
48 group_oc_name = group_oc->soc_oid;
52 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
53 "ldbm_back_group: check (%s) member of (%s), oc %s\n",
54 op_ndn, gr_ndn, group_oc_name ));
56 Debug( LDAP_DEBUG_ARGS,
57 "=> ldbm_back_group: gr dn: \"%s\"\n",
60 Debug( LDAP_DEBUG_ARGS,
61 "=> ldbm_back_group: op dn: \"%s\"\n",
63 Debug( LDAP_DEBUG_ARGS,
64 "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n",
65 group_oc_name, group_at_name, 0 );
67 Debug( LDAP_DEBUG_ARGS,
68 "=> ldbm_back_group: tr dn: \"%s\"\n",
69 target->e_ndn, 0, 0 );
72 if (strcmp(target->e_ndn, gr_ndn) == 0) {
73 /* we already have a LOCKED copy of the entry */
76 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
77 "ldbm_back_group: target is group (%s)\n", gr_ndn ));
79 Debug( LDAP_DEBUG_ARGS,
80 "=> ldbm_back_group: target is group: \"%s\"\n",
86 /* can we find group entry with reader lock */
87 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
89 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
90 "ldbm_back_group: cannot find group (%s)\n",
93 Debug( LDAP_DEBUG_ACL,
94 "=> ldbm_back_group: cannot find group: \"%s\"\n",
102 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
103 "ldbm_back_group: found group (%s)\n", gr_ndn ));
105 Debug( LDAP_DEBUG_ACL,
106 "=> ldbm_back_group: found group: \"%s\"\n",
112 /* find it's objectClass and member attribute values
113 * make sure this is a group entry
114 * finally test if we can find op_dn in the member attribute value list *
120 if( is_entry_alias( e ) ) {
122 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
123 "ldbm_back_group: group (%s) is an alias\n", gr_ndn ));
125 Debug( LDAP_DEBUG_ACL,
126 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
132 if( is_entry_referral( e ) ) {
134 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
135 "ldbm_back_group: group (%s) is a referral.\n", gr_ndn ));
137 Debug( LDAP_DEBUG_ACL,
138 "<= ldbm_back_group: group is an referral\n", 0, 0, 0 );
144 if( !is_entry_objectclass( e, group_oc ) ) {
146 LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
147 "ldbm_back_group: failed to find %s in objectClass.\n",
150 Debug( LDAP_DEBUG_ACL,
151 "<= ldbm_back_group: failed to find %s in objectClass\n",
152 group_oc_name, 0, 0 );
158 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
160 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
161 "ldbm_back_group: failed to find %s\n", group_at_name ));
163 Debug( LDAP_DEBUG_ACL,
164 "<= ldbm_back_group: failed to find %s\n",
165 group_at_name, 0, 0 );
172 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
173 "ldbm_back_group: found objectClass %s and %s\n",
174 group_oc_name, group_at_name ));
176 Debug( LDAP_DEBUG_ACL,
177 "<= ldbm_back_group: found objectClass %s and %s\n",
178 group_oc_name, group_at_name, 0 );
182 bv.bv_val = (char *) op_ndn;
183 bv.bv_len = strlen( op_ndn );
185 if( value_find( group_at, attr->a_vals, &bv ) != LDAP_SUCCESS ) {
187 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
188 "ldbm_back_group: \"%s\" not in \"%s\": %s\n",
189 op_ndn, gr_ndn, group_at_name ));
191 Debug( LDAP_DEBUG_ACL,
192 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
193 op_ndn, gr_ndn, group_at_name );
202 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
203 "ldbm_back_group: %s is in %s: %s\n",
204 op_ndn, gr_ndn, group_at_name ));
206 Debug( LDAP_DEBUG_ACL,
207 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
208 op_ndn, gr_ndn, group_at_name );
216 /* free entry and reader lock */
217 cache_return_entry_r( &li->li_cache, e );
221 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
222 "ldbm_back_group: rc=%d\n", rc ));
224 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );