1 /* group.c - ldbm backend acl group routine */
11 #include "back-ldbm.h"
12 #include "proto-back-ldbm.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
25 char *objectclassValue,
29 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
32 Attribute *objectClass;
36 Debug( LDAP_DEBUG_TRACE,
37 "=> ldbm_back_group: gr dn: \"%s\"\n",
39 Debug( LDAP_DEBUG_TRACE,
40 "=> ldbm_back_group: op dn: \"%s\"\n",
42 Debug( LDAP_DEBUG_TRACE,
43 "=> ldbm_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
44 objectclassValue, groupattrName, 0 );
46 Debug( LDAP_DEBUG_TRACE,
47 "=> ldbm_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 "=> ldbm_back_group: target is group: \"%s\"\n",
57 /* can we find group entry with reader lock */
58 if ((e = dn2entry_r(be, gr_ndn, &matched )) == NULL) {
59 Debug( LDAP_DEBUG_TRACE,
60 "=> ldbm_back_group: cannot find group: \"%s\" matched: \"%s\"\n",
61 gr_ndn, (matched ? matched : ""), 0 );
66 Debug( LDAP_DEBUG_ARGS,
67 "=> ldbm_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, "<= ldbm_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, "<= ldbm_back_group: failed to find %s\n", groupattrName, 0, 0 );
87 struct berval bvObjectClass;
88 struct berval bvMembers;
90 Debug( LDAP_DEBUG_ARGS, "<= ldbm_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 "<= ldbm_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 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
106 op_ndn, gr_ndn, groupattrName );
109 Debug( LDAP_DEBUG_ACL,
110 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
111 op_ndn, gr_ndn, groupattrName );
117 /* free entry and reader lock */
118 cache_return_entry_r( &li->li_cache, e );
121 Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: rc: %d\n", rc, 0, 0 );