]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
fix substring_comp_candidates logic if intersection of candidates
[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 = dn_normalize_case( ch_strdup( LDAP_ROOT_DSE ));
36         e->e_private = NULL;
37
38         for ( i = 0; i < nbackends; i++ ) {
39                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
40                         val.bv_val = backends[i].be_suffix[j];
41                         val.bv_len = strlen( val.bv_val );
42                         attr_merge( e, "namingContexts", vals );
43                 }
44         }
45
46 #if defined( SLAPD_MONITOR_DN )
47         val.bv_val = SLAPD_MONITOR_DN;
48         val.bv_len = strlen( val.bv_val );
49         attr_merge( e, "namingContexts", vals );
50         /* subschemasubentry is added by send_search_entry() */
51 #endif
52
53 #if defined( SLAPD_CONFIG_DN )
54         val.bv_val = SLAPD_CONFIG_DN;
55         val.bv_len = strlen( val.bv_val );
56         attr_merge( e, "namingContexts", vals );
57 #endif
58
59 #if defined( SLAPD_SCHEMA_DN )
60         val.bv_val = SLAPD_SCHEMA_DN;
61         val.bv_len = strlen( val.bv_val );
62         attr_merge( e, "namingContexts", vals );
63 #endif
64
65         /* altServer unsupported */
66
67         /* supportedControl */
68         for ( i=0; supportedControls[i] != NULL; i++ ) {
69                 val.bv_val = supportedControls[i];
70                 val.bv_len = strlen( val.bv_val );
71                 attr_merge( e, "supportedControl", vals );
72         }
73
74         /* supportedExtension */
75         for ( i=0; supportedExtensions[i] != NULL; i++ ) {
76                 val.bv_val = supportedExtensions[i];
77                 val.bv_len = strlen( val.bv_val );
78                 attr_merge( e, "supportedExtension", vals );
79         }
80
81         /* supportedLDAPVersion */
82         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
83                 sprintf(buf,"%d",i);
84                 val.bv_val = buf;
85                 val.bv_len = strlen( val.bv_val );
86                 attr_merge( e, "supportedLDAPVersion", vals );
87         }
88
89         /* supportedSASLMechanism */
90         for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
91                 val.bv_val = supportedSASLMechanisms[i];
92                 val.bv_len = strlen( val.bv_val );
93                 attr_merge( e, "supportedSASLMechanism", vals );
94         }
95
96         if ( default_referral != NULL ) {
97                 attr_merge( e, "ref", default_referral );
98         }
99
100         send_search_entry( &backends[0], conn, op,
101                 e, attrs, attrsonly, 1, NULL );
102         send_search_result( conn, op, LDAP_SUCCESS,
103                 NULL, NULL, NULL, NULL, 1 );
104
105         entry_free( e );
106 }
107