]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
Should have #ifdef'ed in last commit
[openldap] / servers / slapd / root_dse.c
1 /* $OpenLDAP$ */
2 /* root_dse.c - Provides the ROOT DSA-Specific Entry
3  *
4  * Copyright 1999-2000 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 #ifdef SLAPD_SCHEMA_NOT_COMPAT
30         AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
31         AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts;
32         AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl;
33         AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension;
34         AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion;
35         AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms;
36 #ifdef SLAPD_ACI_ENABLED
37         AttributeDescription *ad_supportedACIMechanisms = slap_schema.si_ad_supportedACIMechanisms;
38 #endif
39         AttributeDescription *ad_ref = slap_schema.si_ad_ref;
40 #else
41         char *ad_objectClass = "objectClass";
42         char *ad_namingContexts = "namingContexts";
43         char *ad_supportedControl = "supportedControl";
44         char *ad_supportedExtension = "supportedExtension";
45         char *ad_supportedLDAPVersion = "supportedLDAPVersion";
46         char *ad_supportedSASLMechanisms = "supportedSASLMechanisms";
47 #ifdef SLAPD_ACI_ENABLED
48         char *ad_supportedACIMechanisms = "supportedACIMechanisms";
49 #endif
50         char *ad_ref = "ref";
51 #endif
52
53         vals[0] = &val;
54         vals[1] = NULL;
55
56         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
57
58         e->e_attrs = NULL;
59         e->e_dn = ch_strdup( LDAP_ROOT_DSE );
60         e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
61         (void) dn_normalize( e->e_ndn );
62         e->e_private = NULL;
63
64         val.bv_val = "top";
65         val.bv_len = sizeof("top")-1;
66         attr_merge( e, ad_objectClass, vals );
67
68         val.bv_val = "LDAProotDSE";
69         val.bv_len = sizeof("LDAProotDSE")-1;
70         attr_merge( e, ad_objectClass, vals );
71
72         for ( i = 0; i < nbackends; i++ ) {
73                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
74                         val.bv_val = backends[i].be_suffix[j];
75                         val.bv_len = strlen( val.bv_val );
76                         attr_merge( e, ad_namingContexts, vals );
77                 }
78         }
79
80         /* altServer unsupported */
81
82         /* supportedControl */
83         for ( i=0; supportedControls[i] != NULL; i++ ) {
84                 val.bv_val = supportedControls[i];
85                 val.bv_len = strlen( val.bv_val );
86                 attr_merge( e, ad_supportedControl, vals );
87         }
88
89         /* supportedExtension */
90         for ( i=0; (val.bv_val = get_supported_extop(i)) != NULL; i++ ) {
91                 val.bv_len = strlen( val.bv_val );
92                 attr_merge( e, ad_supportedExtension, vals );
93         }
94
95         /* supportedLDAPVersion */
96         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
97                 sprintf(buf,"%d",i);
98                 val.bv_val = buf;
99                 val.bv_len = strlen( val.bv_val );
100                 attr_merge( e, ad_supportedLDAPVersion, vals );
101         }
102
103         /* supportedSASLMechanism */
104         if( supportedSASLMechanisms != NULL ) {
105                 for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
106                         val.bv_val = supportedSASLMechanisms[i];
107                         val.bv_len = strlen( val.bv_val );
108                         attr_merge( e, ad_supportedSASLMechanisms, vals );
109                 }
110         }
111
112 #ifdef SLAPD_ACI_ENABLED
113         /* supportedACIMechanisms */
114         for ( i=0; (val.bv_val = get_supported_acimech(i)) != NULL; i++ ) {
115                 val.bv_len = strlen( val.bv_val );
116                 attr_merge( e, ad_supportedACIMechanisms, vals );
117         }
118 #endif
119
120         if ( default_referral != NULL ) {
121                 attr_merge( e, ad_ref, default_referral );
122         }
123
124         send_search_entry( &backends[0], conn, op,
125                 e, attrs, attrsonly, NULL );
126
127         send_search_result( conn, op, LDAP_SUCCESS,
128                 NULL, NULL, NULL, NULL, 1 );
129
130         entry_free( e );
131 }
132