1 /* group.c - ldbm backend acl group routine */
4 * Copyright 1998-2003 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 struct berval *gr_ndn,
31 struct berval *op_ndn,
32 ObjectClass *group_oc,
33 AttributeDescription *group_at
36 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
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;
51 LDAP_LOG( BACK_LDBM, ENTRY,
52 "ldbm_back_group: check (%s) member of (%s), oc %s\n",
53 op_ndn->bv_val, gr_ndn->bv_val, group_oc_name );
55 Debug( LDAP_DEBUG_ARGS,
56 "=> ldbm_back_group: gr dn: \"%s\"\n",
57 gr_ndn->bv_val, 0, 0 );
59 Debug( LDAP_DEBUG_ARGS,
60 "=> ldbm_back_group: op dn: \"%s\"\n",
61 op_ndn->bv_val, 0, 0 );
62 Debug( LDAP_DEBUG_ARGS,
63 "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n",
64 group_oc_name, group_at_name, 0 );
66 Debug( LDAP_DEBUG_ARGS,
67 "=> ldbm_back_group: tr dn: \"%s\"\n",
68 target->e_ndn, 0, 0 );
71 if (dn_match(&target->e_nname, gr_ndn)) {
72 /* we already have a LOCKED copy of the entry */
75 LDAP_LOG( BACK_LDBM, DETAIL1,
76 "ldbm_back_group: target is group (%s)\n", gr_ndn->bv_val, 0, 0 );
78 Debug( LDAP_DEBUG_ARGS,
79 "=> ldbm_back_group: target is group: \"%s\"\n",
80 gr_ndn->bv_val, 0, 0 );
85 /* can we find group entry with reader lock */
86 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
88 LDAP_LOG( BACK_LDBM, DETAIL1,
89 "ldbm_back_group: cannot find group (%s)\n",
90 gr_ndn->bv_val, 0, 0 );
92 Debug( LDAP_DEBUG_ACL,
93 "=> ldbm_back_group: cannot find group: \"%s\"\n",
94 gr_ndn->bv_val, 0, 0 );
101 LDAP_LOG( BACK_LDBM, DETAIL1,
102 "ldbm_back_group: found group (%s)\n", gr_ndn->bv_val, 0, 0 );
104 Debug( LDAP_DEBUG_ACL,
105 "=> ldbm_back_group: found group: \"%s\"\n",
106 gr_ndn->bv_val, 0, 0 );
111 /* find it's objectClass and member attribute values
112 * make sure this is a group entry
113 * finally test if we can find op_dn in the member attribute value list *
119 if( is_entry_alias( e ) ) {
121 LDAP_LOG( BACK_LDBM, INFO,
122 "ldbm_back_group: group (%s) is an alias\n", gr_ndn->bv_val, 0, 0 );
124 Debug( LDAP_DEBUG_ACL,
125 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
131 if( is_entry_referral( e ) ) {
133 LDAP_LOG( BACK_LDBM, INFO,
134 "ldbm_back_group: group (%s) is a referral.\n", gr_ndn->bv_val,0,0);
136 Debug( LDAP_DEBUG_ACL,
137 "<= ldbm_back_group: group is an referral\n", 0, 0, 0 );
143 if( !is_entry_objectclass( e, group_oc, 0 ) ) {
145 LDAP_LOG( BACK_LDBM, ERR,
146 "ldbm_back_group: failed to find %s in objectClass.\n",
147 group_oc_name, 0, 0 );
149 Debug( LDAP_DEBUG_ACL,
150 "<= ldbm_back_group: failed to find %s in objectClass\n",
151 group_oc_name, 0, 0 );
157 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
159 LDAP_LOG( BACK_LDBM, INFO,
160 "ldbm_back_group: failed to find %s\n", group_at_name, 0, 0 );
162 Debug( LDAP_DEBUG_ACL,
163 "<= ldbm_back_group: failed to find %s\n",
164 group_at_name, 0, 0 );
171 LDAP_LOG( BACK_LDBM, ENTRY,
172 "ldbm_back_group: found objectClass %s and %s\n",
173 group_oc_name, group_at_name, 0 );
175 Debug( LDAP_DEBUG_ACL,
176 "<= ldbm_back_group: found objectClass %s and %s\n",
177 group_oc_name, group_at_name, 0 );
181 if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
183 LDAP_LOG( BACK_LDBM, DETAIL1,
184 "ldbm_back_group: \"%s\" not in \"%s\": %s\n",
185 op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
187 Debug( LDAP_DEBUG_ACL,
188 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
189 op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
197 LDAP_LOG( BACK_LDBM, DETAIL1,
198 "ldbm_back_group: %s is in %s: %s\n",
199 op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
201 Debug( LDAP_DEBUG_ACL,
202 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
203 op_ndn->bv_val, gr_ndn->bv_val, group_at_name );
211 /* free entry and reader lock */
212 cache_return_entry_r( &li->li_cache, e );
216 LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_group: rc=%d\n", rc, 0, 0 );
218 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );