]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
Move `#include "ldap_defaults.h"' into slap.h, which #ifdefs on it.
[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 <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_case( 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 #if defined( SLAPD_MONITOR_DN )
49         val.bv_val = SLAPD_MONITOR_DN;
50         val.bv_len = strlen( val.bv_val );
51         attr_merge( e, "namingContexts", vals );
52         /* subschemasubentry is added by send_search_entry() */
53 #endif
54
55 #if defined( SLAPD_CONFIG_DN )
56         val.bv_val = SLAPD_CONFIG_DN;
57         val.bv_len = strlen( val.bv_val );
58         attr_merge( e, "namingContexts", vals );
59 #endif
60
61 #if defined( SLAPD_SCHEMA_DN )
62         val.bv_val = SLAPD_SCHEMA_DN;
63         val.bv_len = strlen( val.bv_val );
64         attr_merge( e, "namingContexts", vals );
65 #endif
66
67         /* altServer unsupported */
68
69         /* supportedControl */
70         for ( i=0; supportedControls[i] != NULL; i++ ) {
71                 val.bv_val = supportedControls[i];
72                 val.bv_len = strlen( val.bv_val );
73                 attr_merge( e, "supportedControl", vals );
74         }
75
76         /* supportedExtension */
77         for ( i=0; supportedExtensions[i] != NULL; i++ ) {
78                 val.bv_val = supportedExtensions[i];
79                 val.bv_len = strlen( val.bv_val );
80                 attr_merge( e, "supportedExtension", vals );
81         }
82
83         /* supportedLDAPVersion */
84         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
85                 sprintf(buf,"%d",i);
86                 val.bv_val = buf;
87                 val.bv_len = strlen( val.bv_val );
88                 attr_merge( e, "supportedLDAPVersion", vals );
89         }
90
91         /* supportedSASLMechanism */
92         if( supportedSASLMechanisms != NULL ) {
93                 for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
94                         val.bv_val = supportedSASLMechanisms[i];
95                         val.bv_len = strlen( val.bv_val );
96                         attr_merge( e, "supportedSASLMechanisms", vals );
97                 }
98         }
99
100         if ( default_referral != NULL ) {
101                 attr_merge( e, "ref", default_referral );
102         }
103
104         val.bv_val = "top";
105         val.bv_len = sizeof("top")-1;
106         attr_merge( e, "objectClass", vals );
107
108         val.bv_val = "LDAPsubentry";
109         val.bv_len = sizeof("LDAPsubentry")-1;
110         attr_merge( e, "objectClass", vals );
111
112         val.bv_val = "extensibleObject";
113         val.bv_len = sizeof("extensibleObject")-1;
114         attr_merge( e, "objectClass", vals );
115
116         send_search_entry( &backends[0], conn, op,
117                 e, attrs, attrsonly, NULL );
118         send_search_result( conn, op, LDAP_SUCCESS,
119                 NULL, NULL, NULL, NULL, 1 );
120
121         entry_free( e );
122 }
123