1 /* group.c - bdb2 backend acl group routine */
11 #include "back-bdb2.h"
12 #include "proto-back-bdb2.h"
15 /* return 0 IFF op_dn is a value in member attribute
16 * of entry with gr_dn AND that entry has an objectClass
17 * value of groupOfNames
20 bdb2i_back_group_internal(
25 char *objectclassValue,
29 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
35 Debug( LDAP_DEBUG_ARGS,
36 "=> bdb2i_back_group: gr dn: \"%s\"\n",
38 Debug( LDAP_DEBUG_ARGS,
39 "=> bdb2i_back_group: op dn: \"%s\"\n",
41 Debug( LDAP_DEBUG_ARGS,
42 "=> bdb2i_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
43 objectclassValue, groupattrName, 0 );
45 Debug( LDAP_DEBUG_ARGS,
46 "=> bdb2i_back_group: tr dn: \"%s\"\n",
47 target->e_ndn, 0, 0 );
49 if (strcmp(target->e_ndn, gr_ndn) == 0) {
50 /* we already have a LOCKED copy of the entry */
52 Debug( LDAP_DEBUG_ARGS,
53 "=> bdb2i_back_group: target is group: \"%s\"\n",
57 /* can we find group entry with reader lock */
58 if ((e = bdb2i_dn2entry_r(be, gr_ndn, NULL )) == NULL) {
59 Debug( LDAP_DEBUG_ACL,
60 "=> bdb2i_back_group: cannot find group: \"%s\"\n",
65 Debug( LDAP_DEBUG_ACL,
66 "=> bdb2i_back_group: found group: \"%s\"\n",
70 /* find it's objectClass and member attribute values
71 * make sure this is a group entry
72 * finally test if we can find op_dn in the member attribute value list
77 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
78 Debug( LDAP_DEBUG_ACL,
79 "<= bdb2i_back_group: failed to find objectClass\n", 0, 0, 0 );
84 bv.bv_len = sizeof("ALIAS")-1;
86 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
87 Debug( LDAP_DEBUG_ACL,
88 "<= bdb2i_back_group: group is an alias\n", 0, 0, 0 );
92 bv.bv_val = "REFERRAL";
93 bv.bv_len = sizeof("REFERRAL")-1;
95 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
96 Debug( LDAP_DEBUG_ACL,
97 "<= bdb2i_back_group: group is a referral\n", 0, 0, 0 );
101 bv.bv_val = objectclassValue;
102 bv.bv_len = strlen( bv.bv_val );
104 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
105 Debug( LDAP_DEBUG_ACL,
106 "<= bdb2i_back_group: failed to find %s in objectClass\n",
107 objectclassValue, 0, 0 );
111 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
112 Debug( LDAP_DEBUG_ACL,
113 "<= bdb2i_back_group: failed to find %s\n",
114 groupattrName, 0, 0 );
118 Debug( LDAP_DEBUG_ACL,
119 "<= bdb2i_back_group: found objectClass %s and %s\n",
120 objectclassValue, groupattrName, 0 );
124 bv.bv_len = strlen( op_ndn );
126 if (value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 ) {
127 Debug( LDAP_DEBUG_ACL,
128 "<= bdb2i_back_group: \"%s\" not in \"%s\": %s\n",
129 op_ndn, gr_ndn, groupattrName );
133 Debug( LDAP_DEBUG_ACL,
134 "<= bdb2i_back_group: \"%s\" is in \"%s\": %s\n",
135 op_ndn, gr_ndn, groupattrName );
140 /* free entry and reader lock */
141 bdb2i_cache_return_entry_r( &li->li_cache, e );
144 Debug( LDAP_DEBUG_ARGS, "bdb2i_back_group: rc: %d\n", rc, 0, 0 );
155 char *objectclassValue,
160 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
161 struct timeval time1;
164 bdb2i_start_timing( be->bd_info, &time1 );
166 if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
172 ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn,
173 objectclassValue, groupattrName );
175 (void) bdb2i_leave_backend_r( lock );
176 bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL );