]> git.sur5r.net Git - openldap/blob - servers/slapd/operational.c
f6b45221f8e889bb4aaf1df6469752877122b818
[openldap] / servers / slapd / operational.c
1 /* operational.c - routines to deal with on-the-fly operational attrs */
2 /*
3  * Copyright 2001-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include "slap.h"
10
11 /*
12  * helpers for on-the-fly operational attribute generation
13  */
14
15 #ifdef SLAPD_SCHEMA_DN
16 Attribute *
17 slap_operational_subschemaSubentry( Backend *be )
18 {
19         Attribute       *a;
20
21         /* The backend wants to take care of it */
22         if ( be && be->be_schemadn.bv_val )
23                 return NULL;
24
25         a = ch_malloc( sizeof( Attribute ) );
26         a->a_desc = slap_schema.si_ad_subschemaSubentry;
27
28         a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
29         ber_dupbv( a->a_vals, &global_schemadn );
30         a->a_vals[1].bv_val = NULL;
31
32         a->a_next = NULL;
33         a->a_flags = 0;
34
35         return a;
36 }
37 #endif /* SLAPD_SCHEMA_DN */
38
39 Attribute *
40 slap_operational_hasSubordinate( int hs )
41 {
42         Attribute       *a;
43         char            *val;
44         ber_len_t       len;
45
46         if ( hs ) {
47                 val = "TRUE";
48                 len = sizeof( "TRUE" ) - 1;
49
50         } else {
51                 val = "FALSE";
52                 len = sizeof( "FALSE" ) - 1;
53
54         }
55
56         a = ch_malloc( sizeof( Attribute ) );
57         a->a_desc = slap_schema.si_ad_hasSubordinates;
58         a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
59
60         ber_str2bv( val, len, 1, a->a_vals );
61         a->a_vals[1].bv_val = NULL;
62
63         a->a_next = NULL;
64         a->a_flags = 0;
65
66         return a;
67 }
68