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