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 #ifdef SLAPD_SCHEMA_NOT_COMPAT
31 ObjectClass *group_oc,
32 AttributeDescription *group_at
39 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
45 #ifdef SLAPD_SCHEMA_NOT_COMPAT
46 AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
47 const char *group_oc_name = NULL;
48 const char *group_at_name = group_at->ad_cname->bv_val;
50 if( group_oc->soc_names && group_oc->soc_names[0] ) {
51 group_oc_name = group_oc->soc_names[0];
53 group_oc_name = group_oc->soc_oid;
56 const char *ad_objectClass = "objectclass";
57 const char *group_oc_name = group_oc;
58 const char *group_at_name = group_at;
61 Debug( LDAP_DEBUG_ARGS,
62 "=> ldbm_back_group: gr dn: \"%s\"\n",
64 Debug( LDAP_DEBUG_ARGS,
65 "=> ldbm_back_group: op dn: \"%s\"\n",
67 Debug( LDAP_DEBUG_ARGS,
68 "=> ldbm_back_group: oc: \"%s\" at: \"%s\"\n",
69 group_oc_name, group_at_name, 0 );
71 Debug( LDAP_DEBUG_ARGS,
72 "=> ldbm_back_group: tr dn: \"%s\"\n",
73 target->e_ndn, 0, 0 );
75 if (strcmp(target->e_ndn, gr_ndn) == 0) {
76 /* we already have a LOCKED copy of the entry */
78 Debug( LDAP_DEBUG_ARGS,
79 "=> ldbm_back_group: target is group: \"%s\"\n",
83 /* can we find group entry with reader lock */
84 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
85 Debug( LDAP_DEBUG_ACL,
86 "=> ldbm_back_group: cannot find group: \"%s\"\n",
91 Debug( LDAP_DEBUG_ACL,
92 "=> ldbm_back_group: found group: \"%s\"\n",
96 /* find it's objectClass and member attribute values
97 * make sure this is a group entry
98 * finally test if we can find op_dn in the member attribute value list *
104 #ifdef SLAPD_SCHEMA_NOT_COMPAT
105 if( is_entry_alias( e ) ) {
106 Debug( LDAP_DEBUG_ACL,
107 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
111 if( is_entry_referral( e ) ) {
112 Debug( LDAP_DEBUG_ACL,
113 "<= ldbm_back_group: group is an referral\n", 0, 0, 0 );
117 if( is_entry_objectclass( e, group_oc ) ) {
118 Debug( LDAP_DEBUG_ACL,
119 "<= ldbm_back_group: failed to find %s in objectClass\n",
120 group_oc_name, 0, 0 );
124 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
125 Debug( LDAP_DEBUG_ACL,
126 "<= ldbm_back_group: failed to find %s\n",
127 group_at_name, 0, 0 );
131 Debug( LDAP_DEBUG_ACL,
132 "<= ldbm_back_group: found objectClass %s and %s\n",
133 group_oc_name, group_at_name, 0 );
135 bv.bv_val = (char *) op_ndn;
136 bv.bv_len = strlen( op_ndn );
138 if( value_find( group_at, attr->a_vals, &bv ) == 0 ) {
139 Debug( LDAP_DEBUG_ACL,
140 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
141 op_ndn, gr_ndn, group_at_name );
146 if ((attr = attr_find(e->e_attrs, ad_objectClass)) == NULL) {
147 Debug( LDAP_DEBUG_ACL,
148 "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
153 bv.bv_len = sizeof("ALIAS")-1;
155 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
156 Debug( LDAP_DEBUG_ACL,
157 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
161 bv.bv_val = "REFERRAL";
162 bv.bv_len = sizeof("REFERRAL")-1;
164 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
165 Debug( LDAP_DEBUG_ACL,
166 "<= ldbm_back_group: group is a referral\n",
171 bv.bv_val = (char *) group_oc_name;
172 bv.bv_len = strlen( bv.bv_val );
174 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
175 Debug( LDAP_DEBUG_ACL,
176 "<= ldbm_back_group: failed to find %s in objectClass\n",
177 group_oc_name, 0, 0 );
181 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
182 Debug( LDAP_DEBUG_ACL,
183 "<= ldbm_back_group: failed to find %s\n",
184 group_at_name, 0, 0 );
188 Debug( LDAP_DEBUG_ACL,
189 "<= ldbm_back_group: found objectClass %s and %s\n",
190 group_oc_name, group_at_name, 0 );
192 bv.bv_val = (char *) op_ndn;
193 bv.bv_len = strlen( op_ndn );
195 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
197 Debug( LDAP_DEBUG_ACL,
198 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
199 op_ndn, gr_ndn, group_at_name );
205 Debug( LDAP_DEBUG_ACL,
206 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
207 op_ndn, gr_ndn, group_at_name );
213 /* free entry and reader lock */
214 cache_return_entry_r( &li->li_cache, e );
217 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );