1 /* group.c - bdb2 backend acl group routine */
12 #include "back-bdb2.h"
13 #include "proto-back-bdb2.h"
16 /* return 0 IFF op_dn is a value in member attribute
17 * of entry with gr_dn AND that entry has an objectClass
18 * value of groupOfNames
21 bdb2i_back_group_internal(
26 const char *objectclassValue,
27 const char *groupattrName
30 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
36 Debug( LDAP_DEBUG_ARGS,
37 "=> bdb2i_back_group: gr dn: \"%s\"\n",
39 Debug( LDAP_DEBUG_ARGS,
40 "=> bdb2i_back_group: op dn: \"%s\"\n",
42 Debug( LDAP_DEBUG_ARGS,
43 "=> bdb2i_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
44 objectclassValue, groupattrName, 0 );
46 Debug( LDAP_DEBUG_ARGS,
47 "=> bdb2i_back_group: tr dn: \"%s\"\n",
48 target->e_ndn, 0, 0 );
50 if (strcmp(target->e_ndn, gr_ndn) == 0) {
51 /* we already have a LOCKED copy of the entry */
53 Debug( LDAP_DEBUG_ARGS,
54 "=> bdb2i_back_group: target is group: \"%s\"\n",
58 /* can we find group entry with reader lock */
59 if ((e = bdb2i_dn2entry_r(be, gr_ndn, NULL )) == NULL) {
60 Debug( LDAP_DEBUG_ACL,
61 "=> bdb2i_back_group: cannot find group: \"%s\"\n",
66 Debug( LDAP_DEBUG_ACL,
67 "=> bdb2i_back_group: found group: \"%s\"\n",
71 /* find it's objectClass and member attribute values
72 * make sure this is a group entry
73 * finally test if we can find op_dn in the member attribute value list
78 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
79 Debug( LDAP_DEBUG_ACL,
80 "<= bdb2i_back_group: failed to find objectClass\n", 0, 0, 0 );
85 bv.bv_len = sizeof("ALIAS")-1;
87 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
88 Debug( LDAP_DEBUG_ACL,
89 "<= bdb2i_back_group: group is an alias\n", 0, 0, 0 );
93 bv.bv_val = "REFERRAL";
94 bv.bv_len = sizeof("REFERRAL")-1;
96 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
97 Debug( LDAP_DEBUG_ACL,
98 "<= bdb2i_back_group: group is a referral\n", 0, 0, 0 );
102 bv.bv_val = (char *) objectclassValue;
103 bv.bv_len = strlen( bv.bv_val );
105 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
106 Debug( LDAP_DEBUG_ACL,
107 "<= bdb2i_back_group: failed to find %s in objectClass\n",
108 objectclassValue, 0, 0 );
112 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
113 Debug( LDAP_DEBUG_ACL,
114 "<= bdb2i_back_group: failed to find %s\n",
115 groupattrName, 0, 0 );
119 Debug( LDAP_DEBUG_ACL,
120 "<= bdb2i_back_group: found objectClass %s and %s\n",
121 objectclassValue, groupattrName, 0 );
124 bv.bv_val = (char *) op_ndn;
125 bv.bv_len = strlen( op_ndn );
127 if (value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 ) {
128 Debug( LDAP_DEBUG_ACL,
129 "<= bdb2i_back_group: \"%s\" not in \"%s\": %s\n",
130 op_ndn, gr_ndn, groupattrName );
134 Debug( LDAP_DEBUG_ACL,
135 "<= bdb2i_back_group: \"%s\" is in \"%s\": %s\n",
136 op_ndn, gr_ndn, groupattrName );
141 /* free entry and reader lock */
142 bdb2i_cache_return_entry_r( &li->li_cache, e );
145 Debug( LDAP_DEBUG_ARGS, "bdb2i_back_group: rc: %d\n", rc, 0, 0 );
156 const char *objectclassValue,
157 const char *groupattrName
161 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
162 struct timeval time1;
165 bdb2i_start_timing( be->bd_info, &time1 );
167 if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
173 ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn,
174 objectclassValue, groupattrName );
176 (void) bdb2i_leave_backend_r( lock );
177 bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL );