1 /* compare.c - ldbm backend compare routine */
8 #include <sys/socket.h>
10 #include "back-ldbm.h"
11 #include "proto-back-ldbm.h"
13 extern Attribute *attr_find();
17 /* return 0 IFF edn is a value in uniqueMember attribute
18 * of entry with bdn AND that entry has an objectClass
19 * value of groupOfUniqueNames
28 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
31 Attribute *objectClass;
32 Attribute *uniqueMember;
35 Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: bdn: %s\n", bdn, 0, 0 );
36 Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: edn: %s\n", edn, 0, 0 );
38 /* can we find bdn entry with reader lock */
39 if ((e = dn2entry_r(be, bdn, &matched )) == NULL) {
40 Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %x\n", bdn, matched, 0 );
45 Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %x\n", bdn, matched, 0 );
47 /* check for deleted */
49 /* find it's objectClass and uniqueMember attribute values
50 * make sure this is a group entry
51 * finally test if we can find edn in the uniqueMember attribute value list *
55 if ((objectClass = attr_find(e->e_attrs, "objectclass")) == NULL) {
56 Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
58 else if ((uniqueMember = attr_find(e->e_attrs, "uniquemember")) == NULL) {
59 Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find uniqueMember\n", 0, 0, 0 );
62 struct berval bvObjectClass;
63 struct berval bvUniqueMembers;
65 Debug( LDAP_DEBUG_ARGS, "<= ldbm_back_group: found objectClass and uniqueMembers\n", 0, 0, 0 );
67 bvObjectClass.bv_val = "groupofuniquenames";
68 bvObjectClass.bv_len = strlen( bvObjectClass.bv_val );
69 bvUniqueMembers.bv_val = edn;
70 bvUniqueMembers.bv_len = strlen( edn );
72 if (value_find(objectClass->a_vals, &bvObjectClass, SYNTAX_CIS, 1) != 0) {
73 Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find objectClass in groupOfUniqueNames\n",
76 else if (value_find(uniqueMember->a_vals, &bvUniqueMembers, SYNTAX_CIS, 1) != 0) {
77 Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s not in %s: groupOfUniqueNames\n",
81 Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s is in %s: groupOfUniqueNames\n",
87 /* free entry and reader lock */
88 cache_return_entry_r( &li->li_cache, e );
89 Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: rc: %d\n", rc, 0, 0 );