]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
Adhere to "servers will not return operational attributes" in
[openldap] / servers / slapd / root_dse.c
1 /* root_dse.c - Provides the ROOT DSA-Specific Entry
2  *
3  * Copyright 1999 The OpenLDAP Foundation.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #include "portable.h"
13
14 #include <stdio.h>
15
16 #include "ldap_defaults.h"
17 #include "slap.h"
18
19 void
20 root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
21 {
22         char buf[BUFSIZ];
23         Entry           *e;
24         struct berval   val;
25         struct berval   *vals[2];
26         int             i, j;
27
28         vals[0] = &val;
29         vals[1] = NULL;
30
31         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
32
33         e->e_attrs = NULL;
34         e->e_dn = ch_strdup( LDAP_ROOT_DSE );
35         e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
36         (void) dn_normalize_case( e->e_ndn );
37         e->e_private = NULL;
38
39         for ( i = 0; i < nbackends; i++ ) {
40                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
41                         val.bv_val = backends[i].be_suffix[j];
42                         val.bv_len = strlen( val.bv_val );
43                         attr_merge( e, "namingContexts", vals );
44                 }
45         }
46
47 #if defined( SLAPD_MONITOR_DN )
48         val.bv_val = SLAPD_MONITOR_DN;
49         val.bv_len = strlen( val.bv_val );
50         attr_merge( e, "namingContexts", vals );
51         /* subschemasubentry is added by send_search_entry() */
52 #endif
53
54 #if defined( SLAPD_CONFIG_DN )
55         val.bv_val = SLAPD_CONFIG_DN;
56         val.bv_len = strlen( val.bv_val );
57         attr_merge( e, "namingContexts", vals );
58 #endif
59
60 #if defined( SLAPD_SCHEMA_DN )
61         val.bv_val = SLAPD_SCHEMA_DN;
62         val.bv_len = strlen( val.bv_val );
63         attr_merge( e, "namingContexts", vals );
64 #endif
65
66         /* altServer unsupported */
67
68         /* supportedControl */
69         for ( i=0; supportedControls[i] != NULL; i++ ) {
70                 val.bv_val = supportedControls[i];
71                 val.bv_len = strlen( val.bv_val );
72                 attr_merge( e, "supportedControl", vals );
73         }
74
75         /* supportedExtension */
76         for ( i=0; supportedExtensions[i] != NULL; i++ ) {
77                 val.bv_val = supportedExtensions[i];
78                 val.bv_len = strlen( val.bv_val );
79                 attr_merge( e, "supportedExtension", vals );
80         }
81
82         /* supportedLDAPVersion */
83         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
84                 sprintf(buf,"%d",i);
85                 val.bv_val = buf;
86                 val.bv_len = strlen( val.bv_val );
87                 attr_merge( e, "supportedLDAPVersion", vals );
88         }
89
90         /* supportedSASLMechanism */
91         for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
92                 val.bv_val = supportedSASLMechanisms[i];
93                 val.bv_len = strlen( val.bv_val );
94                 attr_merge( e, "supportedSASLMechanisms", vals );
95         }
96
97         if ( default_referral != NULL ) {
98                 attr_merge( e, "ref", default_referral );
99         }
100
101         send_search_entry( &backends[0], conn, op,
102                 e, attrs, attrsonly, 0, NULL );
103         send_search_result( conn, op, LDAP_SUCCESS,
104                 NULL, NULL, NULL, NULL, 1 );
105
106         entry_free( e );
107 }
108