]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
Add OpenLDAP RCSid to *.[ch] in clients, libraries, and servers.
[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
17 #include <ac/string.h>
18
19 #include "slap.h"
20
21 void
22 root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
23 {
24         char buf[BUFSIZ];
25         Entry           *e;
26         struct berval   val;
27         struct berval   *vals[2];
28         int             i, j;
29
30         vals[0] = &val;
31         vals[1] = NULL;
32
33         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
34
35         e->e_attrs = NULL;
36         e->e_dn = ch_strdup( LDAP_ROOT_DSE );
37         e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
38         (void) dn_normalize_case( e->e_ndn );
39         e->e_private = NULL;
40
41         for ( i = 0; i < nbackends; i++ ) {
42                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
43                         val.bv_val = backends[i].be_suffix[j];
44                         val.bv_len = strlen( val.bv_val );
45                         attr_merge( e, "namingContexts", vals );
46                 }
47         }
48
49 #if defined( SLAPD_MONITOR_DN )
50         val.bv_val = SLAPD_MONITOR_DN;
51         val.bv_len = strlen( val.bv_val );
52         attr_merge( e, "namingContexts", vals );
53         /* subschemasubentry is added by send_search_entry() */
54 #endif
55
56 #if defined( SLAPD_CONFIG_DN )
57         val.bv_val = SLAPD_CONFIG_DN;
58         val.bv_len = strlen( val.bv_val );
59         attr_merge( e, "namingContexts", vals );
60 #endif
61
62 #if defined( SLAPD_SCHEMA_DN )
63         val.bv_val = SLAPD_SCHEMA_DN;
64         val.bv_len = strlen( val.bv_val );
65         attr_merge( e, "namingContexts", vals );
66 #endif
67
68         /* altServer unsupported */
69
70         /* supportedControl */
71         for ( i=0; supportedControls[i] != NULL; i++ ) {
72                 val.bv_val = supportedControls[i];
73                 val.bv_len = strlen( val.bv_val );
74                 attr_merge( e, "supportedControl", vals );
75         }
76
77         /* supportedExtension */
78         for ( i=0; supportedExtensions[i] != NULL; i++ ) {
79                 val.bv_val = supportedExtensions[i];
80                 val.bv_len = strlen( val.bv_val );
81                 attr_merge( e, "supportedExtension", vals );
82         }
83
84         /* supportedLDAPVersion */
85         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
86                 sprintf(buf,"%d",i);
87                 val.bv_val = buf;
88                 val.bv_len = strlen( val.bv_val );
89                 attr_merge( e, "supportedLDAPVersion", vals );
90         }
91
92         /* supportedSASLMechanism */
93         if( supportedSASLMechanisms != NULL ) {
94                 for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
95                         val.bv_val = supportedSASLMechanisms[i];
96                         val.bv_len = strlen( val.bv_val );
97                         attr_merge( e, "supportedSASLMechanisms", vals );
98                 }
99         }
100
101         if ( default_referral != NULL ) {
102                 attr_merge( e, "ref", default_referral );
103         }
104
105         val.bv_val = "top";
106         val.bv_len = sizeof("top")-1;
107         attr_merge( e, "objectClass", vals );
108
109         val.bv_val = "LDAPsubentry";
110         val.bv_len = sizeof("LDAPsubentry")-1;
111         attr_merge( e, "objectClass", vals );
112
113         val.bv_val = "extensibleObject";
114         val.bv_len = sizeof("extensibleObject")-1;
115         attr_merge( e, "objectClass", vals );
116
117         send_search_entry( &backends[0], conn, op,
118                 e, attrs, attrsonly, NULL );
119         send_search_result( conn, op, LDAP_SUCCESS,
120                 NULL, NULL, NULL, NULL, 1 );
121
122         entry_free( e );
123 }
124