1 /* group.c - bdb 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>
17 #include "proto-bdb.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 bdbinfo *li = (struct bdbinfo *) be->be_private;
42 AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
43 const char *group_oc_name = NULL;
44 const char *group_at_name = group_at->ad_cname.bv_val;
46 if( group_oc->soc_names && group_oc->soc_names[0] ) {
47 group_oc_name = group_oc->soc_names[0];
49 group_oc_name = group_oc->soc_oid;
53 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
54 "bdb_group: check (%s) member of (%s), oc %s\n",
55 op_ndn, gr_ndn, group_oc_name ));
57 Debug( LDAP_DEBUG_ARGS,
58 "=> bdb_group: gr dn: \"%s\"\n",
61 Debug( LDAP_DEBUG_ARGS,
62 "=> bdb_group: op dn: \"%s\"\n",
64 Debug( LDAP_DEBUG_ARGS,
65 "=> bdb_group: oc: \"%s\" at: \"%s\"\n",
66 group_oc_name, group_at_name, 0 );
68 Debug( LDAP_DEBUG_ARGS,
69 "=> bdb_group: tr dn: \"%s\"\n",
70 target->e_ndn, 0, 0 );
73 if (strcmp(target->e_ndn, gr_ndn) == 0) {
74 /* we already have a LOCKED copy of the entry */
77 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
78 "bdb_group: target is group (%s)\n", gr_ndn ));
80 Debug( LDAP_DEBUG_ARGS,
81 "=> bdb_group: target is group: \"%s\"\n",
85 /* can we find group entry */
86 rc = bdb_dn2entry( be, NULL, gr_ndn, &e, NULL, 0 );
92 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
93 "bdb_group: cannot find group (%s)\n",
96 Debug( LDAP_DEBUG_ACL,
97 "=> bdb_group: cannot find group: \"%s\"\n",
103 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
104 "bdb_group: found group (%s)\n", gr_ndn ));
106 Debug( LDAP_DEBUG_ACL,
107 "=> bdb_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
118 if( is_entry_alias( e ) ) {
120 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
121 "bdb_group: group (%s) is an alias\n", gr_ndn ));
123 Debug( LDAP_DEBUG_ACL,
124 "<= bdb_group: group is an alias\n", 0, 0, 0 );
129 if( is_entry_referral( e ) ) {
131 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
132 "bdb_group: group (%s) is a referral.\n", gr_ndn ));
134 Debug( LDAP_DEBUG_ACL,
135 "<= bdb_group: group is a referral\n", 0, 0, 0 );
140 if( !is_entry_objectclass( e, group_oc ) ) {
142 LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
143 "bdb_group: failed to find %s in objectClass.\n",
146 Debug( LDAP_DEBUG_ACL,
147 "<= bdb_group: failed to find %s in objectClass\n",
148 group_oc_name, 0, 0 );
153 if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
155 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
156 "bdb_group: failed to find %s\n", group_at_name ));
158 Debug( LDAP_DEBUG_ACL,
159 "<= bdb_group: failed to find %s\n",
160 group_at_name, 0, 0 );
166 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
167 "bdb_group: found objectClass %s and %s\n",
168 group_oc_name, group_at_name ));
170 Debug( LDAP_DEBUG_ACL,
171 "<= bdb_group: found objectClass %s and %s\n",
172 group_oc_name, group_at_name, 0 );
175 bv.bv_val = (char *) op_ndn;
176 bv.bv_len = strlen( op_ndn );
178 if( value_find( group_at, attr->a_vals, &bv ) != LDAP_SUCCESS ) {
180 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
181 "bdb_group: \"%s\" not in \"%s\": %s\n",
182 op_ndn, gr_ndn, group_at_name ));
184 Debug( LDAP_DEBUG_ACL,
185 "<= bdb_group: \"%s\" not in \"%s\": %s\n",
186 op_ndn, gr_ndn, group_at_name );
192 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
193 "bdb_group: %s is in %s: %s\n",
194 op_ndn, gr_ndn, group_at_name ));
196 Debug( LDAP_DEBUG_ACL,
197 "<= bdb_group: \"%s\" is in \"%s\": %s\n",
198 op_ndn, gr_ndn, group_at_name );
206 bdb_entry_return( be, e );
210 LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
211 "bdb_group: rc=%d\n", rc ));
213 Debug( LDAP_DEBUG_TRACE, "bdb_group: rc=%d\n", rc, 0, 0 );