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 #ifdef SLAPD_SCHEMA_NOT_COMPAT
32 AttributeType *group_at
34 const char *groupattrName
38 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
45 #ifdef SLAPD_SCHEMA_NOT_COMPAT
46 char *groupattrName = at_canonical_name( group_at );
49 Debug( LDAP_DEBUG_ARGS,
50 "=> ldbm_back_group: gr dn: \"%s\"\n",
52 Debug( LDAP_DEBUG_ARGS,
53 "=> ldbm_back_group: op dn: \"%s\"\n",
55 Debug( LDAP_DEBUG_ARGS,
56 "=> ldbm_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
57 objectclassValue, groupattrName, 0 );
59 Debug( LDAP_DEBUG_ARGS,
60 "=> ldbm_back_group: tr dn: \"%s\"\n",
61 target->e_ndn, 0, 0 );
63 if (strcmp(target->e_ndn, gr_ndn) == 0) {
64 /* we already have a LOCKED copy of the entry */
66 Debug( LDAP_DEBUG_ARGS,
67 "=> ldbm_back_group: target is group: \"%s\"\n",
71 /* can we find group entry with reader lock */
72 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
73 Debug( LDAP_DEBUG_ACL,
74 "=> ldbm_back_group: cannot find group: \"%s\"\n",
79 Debug( LDAP_DEBUG_ACL,
80 "=> ldbm_back_group: found group: \"%s\"\n",
84 /* find it's objectClass and member attribute values
85 * make sure this is a group entry
86 * finally test if we can find op_dn in the member attribute value list *
91 #ifdef SLAPD_SCHEMA_NOT_COMPAT
92 /* not yet implemented */
95 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
96 Debug( LDAP_DEBUG_ACL,
97 "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
102 bv.bv_len = sizeof("ALIAS")-1;
104 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
105 Debug( LDAP_DEBUG_ACL,
106 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
110 bv.bv_val = "REFERRAL";
111 bv.bv_len = sizeof("REFERRAL")-1;
113 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
114 Debug( LDAP_DEBUG_ACL,
115 "<= ldbm_back_group: group is a referral\n",
120 bv.bv_val = (char *) objectclassValue;
121 bv.bv_len = strlen( bv.bv_val );
123 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
124 Debug( LDAP_DEBUG_ACL,
125 "<= ldbm_back_group: failed to find %s in objectClass\n",
126 objectclassValue, 0, 0 );
130 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
131 Debug( LDAP_DEBUG_ACL,
132 "<= ldbm_back_group: failed to find %s\n",
133 groupattrName, 0, 0 );
137 Debug( LDAP_DEBUG_ACL,
138 "<= ldbm_back_group: found objectClass %s and %s\n",
139 objectclassValue, groupattrName, 0 );
141 bv.bv_val = (char *) op_ndn;
142 bv.bv_len = strlen( op_ndn );
144 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
146 Debug( LDAP_DEBUG_ACL,
147 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
148 op_ndn, gr_ndn, groupattrName );
152 Debug( LDAP_DEBUG_ACL,
153 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
154 op_ndn, gr_ndn, groupattrName );
161 /* free entry and reader lock */
162 cache_return_entry_r( &li->li_cache, e );
165 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );