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;
32 Attribute *objectClass;
36 Debug( LDAP_DEBUG_TRACE,
37 "=> bdb2i_back_group: gr dn: \"%s\"\n",
39 Debug( LDAP_DEBUG_TRACE,
40 "=> bdb2i_back_group: op dn: \"%s\"\n",
42 Debug( LDAP_DEBUG_TRACE,
43 "=> bdb2i_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
44 objectclassValue, groupattrName, 0 );
46 Debug( LDAP_DEBUG_TRACE,
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",
57 /* can we find group entry with reader lock */
58 if ((e = bdb2i_dn2entry_r(be, gr_ndn, &matched )) == NULL) {
59 Debug( LDAP_DEBUG_TRACE,
60 "=> bdb2i_back_group: cannot find group: \"%s\" matched: \"%s\"\n",
61 gr_ndn, (matched ? matched : ""), 0 );
66 Debug( LDAP_DEBUG_ARGS,
67 "=> bdb2i_back_group: found group: \"%s\"\n",
72 /* check for deleted */
74 /* find it's objectClass and member attribute values
75 * make sure this is a group entry
76 * finally test if we can find op_dn in the member attribute value list *
80 if ((objectClass = attr_find(e->e_attrs, "objectclass")) == NULL) {
81 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_back_group: failed to find objectClass\n", 0, 0, 0 );
83 else if ((member = attr_find(e->e_attrs, groupattrName)) == NULL) {
84 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_back_group: failed to find %s\n", groupattrName, 0, 0 );
87 struct berval bvObjectClass;
88 struct berval bvMembers;
90 Debug( LDAP_DEBUG_ARGS, "<= bdb2i_back_group: found objectClass and %s\n", groupattrName, 0, 0 );
92 bvObjectClass.bv_val = objectclassValue;
93 bvObjectClass.bv_len = strlen( bvObjectClass.bv_val );
95 bvMembers.bv_val = op_ndn;
96 bvMembers.bv_len = strlen( op_ndn );
98 if (value_find(objectClass->a_vals, &bvObjectClass, SYNTAX_CIS, 1) != 0) {
99 Debug( LDAP_DEBUG_TRACE,
100 "<= bdb2i_back_group: failed to find %s in objectClass\n",
101 objectclassValue, 0, 0 );
103 else if (value_find(member->a_vals, &bvMembers, SYNTAX_CIS, 1) != 0) {
104 Debug( LDAP_DEBUG_ACL,
105 "<= bdb2i_back_group: \"%s\" not in \"%s\": %s\n",
106 op_ndn, gr_ndn, groupattrName );
109 Debug( LDAP_DEBUG_ACL,
110 "<= bdb2i_back_group: \"%s\" is in \"%s\": %s\n",
111 op_ndn, gr_ndn, groupattrName );
117 /* free entry and reader lock */
118 bdb2i_cache_return_entry_r( &li->li_cache, e );
121 Debug( LDAP_DEBUG_ARGS, "bdb2i_back_group: rc: %d\n", rc, 0, 0 );
132 char *objectclassValue,
137 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
138 struct timeval time1;
141 bdb2i_start_timing( be->bd_info, &time1 );
143 if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
149 ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn,
150 objectclassValue, groupattrName );
152 (void) bdb2i_leave_backend_r( lock );
153 bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL );