]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/operational.c
2f312217ef5815f52fd4847e9d57a211ce9d2fb0
[openldap] / servers / slapd / back-monitor / operational.c
1 /* operational.c - monitor backend operational attributes function */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2001-2017 The OpenLDAP Foundation.
6  * Portions Copyright 2001-2003 Pierangelo Masarati.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by Pierangelo Masarati for inclusion
19  * in OpenLDAP Software.
20  */
21
22 #include "portable.h"
23
24 #include <stdio.h>
25
26 #include <ac/string.h>
27 #include <ac/socket.h>
28
29 #include "slap.h"
30 #include "back-monitor.h"
31 #include "proto-back-monitor.h"
32
33 /*
34  * sets the supported operational attributes (if required)
35  */
36
37 int
38 monitor_back_operational(
39         Operation       *op,
40         SlapReply       *rs )
41 {
42         Attribute       **ap;
43
44         assert( rs->sr_entry != NULL );
45
46         for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
47                 if ( (*ap)->a_desc == slap_schema.si_ad_hasSubordinates ) {
48                         break;
49                 }
50         }
51
52         if ( *ap == NULL &&
53                 attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL &&
54                 ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
55                         ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) )
56         {
57                 int                     hs;
58                 monitor_entry_t *mp;
59
60                 mp = ( monitor_entry_t * )rs->sr_entry->e_private;
61
62                 assert( mp != NULL );
63
64                 hs = MONITOR_HAS_CHILDREN( mp );
65                 *ap = slap_operational_hasSubordinate( hs );
66                 assert( *ap != NULL );
67                 ap = &(*ap)->a_next;
68         }
69         
70         return LDAP_SUCCESS;
71 }
72