]> git.sur5r.net Git - openldap/blob - servers/slapd/root_dse.c
Extend value_match to extract an asserted value from a full value
[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 static char *supportedFeatures[] = {
21         "1.3.6.1.4.1.4203.1.5.1", /* All Operational Attributes ("+") */
22         NULL
23 };
24
25
26 int
27 root_dse_info(
28         Connection *conn,
29         Entry **entry,
30         const char **text )
31 {
32         char buf[BUFSIZ];
33         Entry           *e;
34         struct berval   val;
35         struct berval   *vals[2];
36         int             i, j;
37         char ** supportedSASLMechanisms;
38
39         AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
40         AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts;
41         AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl;
42         AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension;
43         AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion;
44         AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms;
45         AttributeDescription *ad_supportedFeatures = slap_schema.si_ad_supportedFeatures;
46         AttributeDescription *ad_ref = slap_schema.si_ad_ref;
47
48         vals[0] = &val;
49         vals[1] = NULL;
50
51         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
52
53         e->e_attrs = NULL;
54         e->e_dn = ch_strdup( LDAP_ROOT_DSE );
55         e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
56         (void) dn_normalize( e->e_ndn );
57         e->e_private = NULL;
58
59         val.bv_val = "top";
60         val.bv_len = sizeof("top")-1;
61         attr_merge( e, ad_objectClass, vals );
62
63         val.bv_val = "OpenLDAProotDSE";
64         val.bv_len = sizeof("OpenLDAProotDSE")-1;
65         attr_merge( e, ad_objectClass, vals );
66
67         for ( i = 0; i < nbackends; i++ ) {
68                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
69                         val.bv_val = backends[i].be_suffix[j];
70                         val.bv_len = strlen( val.bv_val );
71                         attr_merge( e, ad_namingContexts, vals );
72                 }
73         }
74
75         /* altServer unsupported */
76
77         /* supportedControl */
78         for ( i=0; supportedControls[i] != NULL; i++ ) {
79                 val.bv_val = supportedControls[i];
80                 val.bv_len = strlen( val.bv_val );
81                 attr_merge( e, ad_supportedControl, vals );
82         }
83
84         /* supportedExtension */
85         for ( i=0; (val.bv_val = get_supported_extop(i)) != NULL; i++ ) {
86                 val.bv_len = strlen( val.bv_val );
87                 attr_merge( e, ad_supportedExtension, vals );
88         }
89
90         /* supportedFeatures */
91         for ( i=0; supportedFeatures[i] != NULL; i++ ) {
92                 val.bv_val = supportedFeatures[i];
93                 val.bv_len = strlen( val.bv_val );
94                 attr_merge( e, ad_supportedFeatures, vals );
95         }
96
97         /* supportedLDAPVersion */
98         for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
99                 if (( global_disallows & SLAP_DISALLOW_BIND_V2 ) &&
100                         ( i < LDAP_VERSION3 ) )
101                 {
102                         /* version 2 and lower are disallowed */
103                         continue;
104                 }
105                 sprintf(buf,"%d",i);
106                 val.bv_val = buf;
107                 val.bv_len = strlen( val.bv_val );
108                 attr_merge( e, ad_supportedLDAPVersion, vals );
109         }
110
111         /* supportedSASLMechanism */
112         supportedSASLMechanisms = slap_sasl_mechs( conn );
113
114         if( supportedSASLMechanisms != NULL ) {
115                 for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
116                         val.bv_val = supportedSASLMechanisms[i];
117                         val.bv_len = strlen( val.bv_val );
118                         attr_merge( e, ad_supportedSASLMechanisms, vals );
119                 }
120         }
121
122         if ( default_referral != NULL ) {
123                 attr_merge( e, ad_ref, default_referral );
124         }
125
126         *entry = e;
127         return LDAP_SUCCESS;
128 }
129