1 /* group.c - ldbm backend acl group routine */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/socket.h>
12 #include <ac/string.h>
15 #include "back-ldbm.h"
16 #include "proto-back-ldbm.h"
19 /* return 0 IFF op_dn is a value in member attribute
20 * of entry with gr_dn AND that entry has an objectClass
21 * value of groupOfNames
29 char *objectclassValue,
33 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
40 Debug( LDAP_DEBUG_ARGS,
41 "=> ldbm_back_group: gr dn: \"%s\"\n",
43 Debug( LDAP_DEBUG_ARGS,
44 "=> ldbm_back_group: op dn: \"%s\"\n",
46 Debug( LDAP_DEBUG_ARGS,
47 "=> ldbm_back_group: objectClass: \"%s\" attrName: \"%s\"\n",
48 objectclassValue, groupattrName, 0 );
50 Debug( LDAP_DEBUG_ARGS,
51 "=> ldbm_back_group: tr dn: \"%s\"\n",
52 target->e_ndn, 0, 0 );
54 if (strcmp(target->e_ndn, gr_ndn) == 0) {
55 /* we already have a LOCKED copy of the entry */
57 Debug( LDAP_DEBUG_ARGS,
58 "=> ldbm_back_group: target is group: \"%s\"\n",
62 /* can we find group entry with reader lock */
63 if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
64 Debug( LDAP_DEBUG_ACL,
65 "=> ldbm_back_group: cannot find group: \"%s\"\n",
70 Debug( LDAP_DEBUG_ACL,
71 "=> ldbm_back_group: found group: \"%s\"\n",
75 /* find it's objectClass and member attribute values
76 * make sure this is a group entry
77 * finally test if we can find op_dn in the member attribute value list *
82 if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) {
83 Debug( LDAP_DEBUG_ACL,
84 "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
89 bv.bv_len = sizeof("ALIAS")-1;
91 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
92 Debug( LDAP_DEBUG_ACL,
93 "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
97 bv.bv_val = "REFERRAL";
98 bv.bv_len = sizeof("REFERRAL")-1;
100 if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
101 Debug( LDAP_DEBUG_ACL,
102 "<= ldbm_back_group: group is a referral\n",
107 bv.bv_val = objectclassValue;
108 bv.bv_len = strlen( bv.bv_val );
110 if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
111 Debug( LDAP_DEBUG_ACL,
112 "<= ldbm_back_group: failed to find %s in objectClass\n",
113 objectclassValue, 0, 0 );
117 if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) {
118 Debug( LDAP_DEBUG_ACL,
119 "<= ldbm_back_group: failed to find %s\n",
120 groupattrName, 0, 0 );
124 Debug( LDAP_DEBUG_ACL,
125 "<= ldbm_back_group: found objectClass %s and %s\n",
126 objectclassValue, groupattrName, 0 );
129 bv.bv_len = strlen( op_ndn );
131 if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
133 Debug( LDAP_DEBUG_ACL,
134 "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
135 op_ndn, gr_ndn, groupattrName );
139 Debug( LDAP_DEBUG_ACL,
140 "<= ldbm_back_group: \"%s\" is in \"%s\": %s\n",
141 op_ndn, gr_ndn, groupattrName );
147 /* free entry and reader lock */
148 cache_return_entry_r( &li->li_cache, e );
151 Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: rc=%d\n", rc, 0, 0 );