]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/operational.c
ITS#4310 seems to affect also back-ldbm
[openldap] / servers / slapd / back-ldbm / operational.c
1 /* operational.c - ldbm backend operational attributes function */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2006 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/string.h>
22 #include <ac/socket.h>
23
24 #include "slap.h"
25 #include "back-ldbm.h"
26 #include "proto-back-ldbm.h"
27
28 /*
29  * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
30  * if the entry has children or not.
31  */
32 int
33 ldbm_back_hasSubordinates(
34         Operation       *op,
35         Entry           *e,
36         int             *hasSubordinates )
37 {
38         if ( has_children( op->o_bd, e ) ) {
39                 *hasSubordinates = LDAP_COMPARE_TRUE;
40
41         } else {
42                 *hasSubordinates = LDAP_COMPARE_FALSE;
43         }
44
45         return 0;
46 }
47
48 /*
49  * sets the supported operational attributes (if required)
50  */
51 int
52 ldbm_back_operational(
53         Operation       *op,
54         SlapReply       *rs )
55 {
56         Attribute       **ap;
57
58         assert( rs->sr_entry != NULL );
59
60         for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
61                 /* just count */ ;
62
63         if ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
64                         ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
65         {
66                 int     hs;
67
68                 hs = has_children( op->o_bd, rs->sr_entry );
69                 *ap = slap_operational_hasSubordinate( hs );
70                 assert( *ap != NULL );
71
72                 ap = &(*ap)->a_next;
73         }
74
75         return 0;
76 }
77