1 /* group.c - ldbm backend acl group routine */
4 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
17 #include "proto-back-ldbm.h"
20 /* return 0 IFF op_dn is a value in member attribute
21 * of entry with gr_dn AND that entry has an objectClass
22 * value of groupOfNames
30 const char *objectclassValue,
31 const char *groupattrName
34 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
41 Debug( LDAP_DEBUG_ARGS,
42 "=> ldbm_back_group: gr dn: \"%s\"\n",
44 Debug( LDAP_DEBUG_ARGS,
45 "=> ldbm_back_group: op dn: \"%s\"\n",
47 Debug( LDAP_DEBUG_ARGS,
48 "=> ldbm_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
49 objectclassValue, groupattrName, 0 );
51 Debug( LDAP_DEBUG_ARGS,
52 "=> ldbm_back_group: tr dn: \"%s\"\n",
53 target->e_ndn, 0, 0 );
55 if (strcmp(target->e_ndn, gr_ndn) == 0) {
56 /* we already have a LOCKED copy of the entry */
58 Debug( LDAP_DEBUG_ARGS,
59 "=> ldbm_back_group: target is group: \"%s\"\n",
63 /* can we find group entry with reader lock */
64 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
65 Debug( LDAP_DEBUG_ACL,
66 "=> ldbm_back_group: cannot find group: \"%s\"\n",
71 Debug( LDAP_DEBUG_ACL,
72 "=> ldbm_back_group: found group: \"%s\"\n",
76 /* find it's objectClass and member attribute values
77 * make sure this is a group entry
78 * finally test if we can find op_dn in the member attribute value list *
83 #ifdef SLAPD_SCHEMA_COMPAT
85 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
86 Debug( LDAP_DEBUG_ACL,
87 "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
92 bv.bv_len = sizeof("ALIAS")-1;
94 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
95 Debug( LDAP_DEBUG_ACL,
96 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
100 bv.bv_val = "REFERRAL";
101 bv.bv_len = sizeof("REFERRAL")-1;
103 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
104 Debug( LDAP_DEBUG_ACL,
105 "<= ldbm_back_group: group is a referral\n",
110 bv.bv_val = (char *) objectclassValue;
111 bv.bv_len = strlen( bv.bv_val );
113 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
114 Debug( LDAP_DEBUG_ACL,
115 "<= ldbm_back_group: failed to find %s in objectClass\n",
116 objectclassValue, 0, 0 );
120 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
121 Debug( LDAP_DEBUG_ACL,
122 "<= ldbm_back_group: failed to find %s\n",
123 groupattrName, 0, 0 );
127 Debug( LDAP_DEBUG_ACL,
128 "<= ldbm_back_group: found objectClass %s and %s\n",
129 objectclassValue, groupattrName, 0 );
131 bv.bv_val = (char *) op_ndn;
132 bv.bv_len = strlen( op_ndn );
134 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
136 Debug( LDAP_DEBUG_ACL,
137 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
138 op_ndn, gr_ndn, groupattrName );
142 Debug( LDAP_DEBUG_ACL,
143 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
144 op_ndn, gr_ndn, groupattrName );
151 /* free entry and reader lock */
152 cache_return_entry_r( &li->li_cache, e );
155 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );