]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
modify be_referral to use struct berval DNs.
[openldap] / servers / slapd / configinfo.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1995 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21
22 #include <ac/string.h>
23 #include <ac/socket.h>
24
25 #include "slap.h"
26
27 #if defined( SLAPD_CONFIG_DN )
28
29 /*
30  * no mutex protection in here - take our chances!
31  */
32
33 int
34 config_info(
35         Entry **entry, const char **text )
36 {
37         Entry           *e;
38         char            buf[BUFSIZ];
39         struct berval   val, *ndn = NULL;
40         struct berval   *vals[2];
41         int             i, j;
42
43         vals[0] = &val;
44         vals[1] = NULL;
45
46         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
47         e->e_private = NULL;
48         e->e_attrs = NULL;
49
50         e->e_name.bv_val = SLAPD_CONFIG_DN;
51         e->e_name.bv_len = sizeof( SLAPD_CONFIG_DN ) - 1;
52
53
54         e->e_attrs = NULL;
55         ber_str2bv( SLAPD_CONFIG_DN, sizeof(SLAPD_CONFIG_DN)-1, 1, &e->e_name );
56         (void) dnNormalize( NULL, &e->e_name, &ndn );
57         e->e_nname = *ndn;
58         free( ndn );
59         e->e_private = NULL;
60
61         val.bv_val = "top";
62         val.bv_len = sizeof("top")-1;
63         attr_merge( e, "objectClass", vals );
64
65         val.bv_val = "LDAPsubentry";
66         val.bv_len = sizeof("LDAPsubentry")-1;
67         attr_merge( e, "objectClass", vals );
68
69         val.bv_val = "extensibleObject";
70         val.bv_len = sizeof("extensibleObject")-1;
71         attr_merge( e, "objectClass", vals );
72
73         {
74                 val.bv_val = strchr( e->e_dn, '=' );
75
76                 if( val.bv_val != NULL ) {
77                         *val.bv_val++ = '\0';
78                         val.bv_len = e->e_name.bv_len - (val.bv_val-e->e_dn);
79
80                         attr_merge( e, rdn, vals );
81                         val.bv_val[-1] = '=';
82                 }
83         }
84
85         for ( i = 0; i < nbackends; i++ ) {
86                 char *ptr = slap_strcopy( buf, backends[i].be_type );
87                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
88                         ptr = slap_strcopy( ptr, " : " );
89                         ptr = slap_strcopy( ptr, backends[i].be_suffix[j]->bv_val );
90                 }
91                 val.bv_val = buf;
92                 val.bv_len = ptr - buf;
93                 attr_merge( e, "database", vals );
94         }
95
96         *entry = e;
97         return LDAP_SUCCESS;
98 }
99
100 #endif /* slapd_config_dn */