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 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
84 Debug( LDAP_DEBUG_ACL,
85 "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
90 bv.bv_len = sizeof("ALIAS")-1;
92 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
93 Debug( LDAP_DEBUG_ACL,
94 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
98 bv.bv_val = "REFERRAL";
99 bv.bv_len = sizeof("REFERRAL")-1;
101 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
102 Debug( LDAP_DEBUG_ACL,
103 "<= ldbm_back_group: group is a referral\n",
108 bv.bv_val = (char *) objectclassValue;
109 bv.bv_len = strlen( bv.bv_val );
111 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
112 Debug( LDAP_DEBUG_ACL,
113 "<= ldbm_back_group: failed to find %s in objectClass\n",
114 objectclassValue, 0, 0 );
118 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
119 Debug( LDAP_DEBUG_ACL,
120 "<= ldbm_back_group: failed to find %s\n",
121 groupattrName, 0, 0 );
125 Debug( LDAP_DEBUG_ACL,
126 "<= ldbm_back_group: found objectClass %s and %s\n",
127 objectclassValue, groupattrName, 0 );
129 bv.bv_val = (char *) op_ndn;
130 bv.bv_len = strlen( op_ndn );
132 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
134 Debug( LDAP_DEBUG_ACL,
135 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
136 op_ndn, gr_ndn, groupattrName );
140 Debug( LDAP_DEBUG_ACL,
141 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
142 op_ndn, gr_ndn, groupattrName );
148 /* free entry and reader lock */
149 cache_return_entry_r( &li->li_cache, e );
152 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );