1 /* group.c - ldap 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-ldap.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 ObjectClass* group_oc,
30 AttributeDescription* group_at
33 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
43 AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
44 const char *group_oc_name = NULL;
45 const char *group_at_name = group_at->ad_cname->bv_val;
47 if( group_oc->soc_names && group_oc->soc_names[0] ) {
48 group_oc_name = group_oc->soc_names[0];
50 group_oc_name = group_oc->soc_oid;
53 if (target != NULL && strcmp(target->e_ndn, gr_ndn) == 0) {
54 /* we already have a copy of the entry */
57 if( is_entry_objectclass( e, group_oc ) ) {
61 if ((attr = attr_find(e->e_attrs, group_at)) == NULL)
64 bv.bv_val = (char *) op_ndn;
65 bv.bv_len = strlen( op_ndn );
66 if( value_find( group_at, attr->a_vals, &bv ) == 0 )
70 filter = ch_malloc(sizeof("(&(objectclass=)(=))")
71 + strlen(group_oc_name)
72 + strlen(group_at_name)
73 + strlen(op_ndn) + 1);
77 if (ldap_initialize(&ld, li->url) != LDAP_SUCCESS) {
82 if (ldap_bind_s(ld, li->binddn, li->bindpw, LDAP_AUTH_SIMPLE) == LDAP_SUCCESS) {
83 strcpy(filter, "(&(objectclass=");
84 strcat(filter, group_oc_name);
86 strcat(filter, group_at_name);
88 strcat(filter, op_ndn);
91 gattr[0] = "objectclass";
93 if (ldap_search_ext_s(ld, gr_ndn, LDAP_SCOPE_BASE, filter,
94 gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
95 LDAP_NO_LIMIT, &result) == LDAP_SUCCESS)
97 if (ldap_first_entry(ld, result) != NULL)