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;
36 Debug( LDAP_DEBUG_ARGS,
37 "=> ldbm_back_group: gr dn: \"%s\"\n",
39 Debug( LDAP_DEBUG_ARGS,
40 "=> ldbm_back_group: op dn: \"%s\"\n",
42 Debug( LDAP_DEBUG_ARGS,
43 "=> ldbm_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
44 objectclassValue, groupattrName, 0 );
46 Debug( LDAP_DEBUG_ARGS,
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",
58 /* can we find group entry with reader lock */
59 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
60 Debug( LDAP_DEBUG_ACL,
61 "=> ldbm_back_group: cannot find group: \"%s\"\n",
66 Debug( LDAP_DEBUG_ACL,
67 "=> ldbm_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 "<= ldbm_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 "<= ldbm_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 "<= ldbm_back_group: group is a referral\n",
103 bv.bv_val = objectclassValue;
104 bv.bv_len = strlen( bv.bv_val );
106 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
107 Debug( LDAP_DEBUG_ACL,
108 "<= ldbm_back_group: failed to find %s in objectClass\n",
109 objectclassValue, 0, 0 );
113 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
114 Debug( LDAP_DEBUG_ACL,
115 "<= ldbm_back_group: failed to find %s\n",
116 groupattrName, 0, 0 );
120 Debug( LDAP_DEBUG_ACL,
121 "<= ldbm_back_group: found objectClass %s and %s\n",
122 objectclassValue, groupattrName, 0 );
125 bv.bv_len = strlen( op_ndn );
127 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
129 Debug( LDAP_DEBUG_ACL,
130 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
131 op_ndn, gr_ndn, groupattrName );
135 Debug( LDAP_DEBUG_ACL,
136 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
137 op_ndn, gr_ndn, groupattrName );
143 /* free entry and reader lock */
144 cache_return_entry_r( &li->li_cache, e );
147 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );