1 /* operational.c - mdb backend operational attributes function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2013 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
21 #include <ac/string.h>
22 #include <ac/socket.h>
28 * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
29 * if the entry has children or not.
35 int *hasSubordinates )
37 struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
39 mdb_op_info opinfo = {{{0}}}, *moi = &opinfo;
44 rc = mdb_opinfo_get(op, mdb, 1, &moi);
55 rc = mdb_dn2id_children( op, rtxn, e );
59 *hasSubordinates = LDAP_COMPARE_TRUE;
63 *hasSubordinates = LDAP_COMPARE_FALSE;
68 Debug(LDAP_DEBUG_ARGS,
69 "<=- " LDAP_XSTRING(mdb_hasSubordinates)
70 ": has_children failed: %s (%d)\n",
71 mdb_strerror(rc), rc, 0 );
76 if ( moi == &opinfo ) {
77 mdb_txn_reset( moi->moi_txn );
78 LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next );
86 * sets the supported operational attributes (if required)
95 assert( rs->sr_entry != NULL );
97 for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
98 if ( (*ap)->a_desc == slap_schema.si_ad_hasSubordinates ) {
104 attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL &&
105 ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
106 ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) )
108 int hasSubordinates, rc;
110 rc = mdb_hasSubordinates( op, rs->sr_entry, &hasSubordinates );
111 if ( rc == LDAP_SUCCESS ) {
112 *ap = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE );
113 assert( *ap != NULL );