]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
Add multimaster replication support (ITS#170) based upon
[openldap] / servers / slapd / configinfo.c
1 /*
2  * Copyright (c) 1995 Regents of the University of Michigan.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of Michigan at Ann Arbor. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16
17 #include <ac/string.h>
18 #include <ac/socket.h>
19
20 #include "ldap_defaults.h"
21 #include "slap.h"
22
23 #if defined( SLAPD_CONFIG_DN )
24
25 /*
26  * no mutex protection in here - take our chances!
27  */
28
29 void
30 config_info(
31         Connection *conn,
32         Operation *op,
33         char **attrs,
34         int attrsonly )
35 {
36         Entry           *e;
37         char            buf[BUFSIZ];
38         struct berval   val;
39         struct berval   *vals[2];
40         int             i, j;
41
42         vals[0] = &val;
43         vals[1] = NULL;
44
45         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
46
47         e->e_attrs = NULL;
48         e->e_dn = ch_strdup( SLAPD_CONFIG_DN );
49         e->e_ndn = ch_strdup( SLAPD_CONFIG_DN );
50         (void) dn_normalize_case( e->e_ndn );
51         e->e_private = NULL;
52
53         {
54                 char *rdn = ch_strdup( SLAPD_CONFIG_DN );
55                 val.bv_val = strchr( rdn, '=' );
56
57                 if( val.bv_val != NULL ) {
58                         *val.bv_val = '\0';
59                         val.bv_len = strlen( ++val.bv_val );
60
61                         attr_merge( e, rdn, vals );
62                 }
63
64                 free( rdn );
65         }
66
67         for ( i = 0; i < nbackends; i++ ) {
68                 strcpy( buf, backends[i].be_type );
69                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
70                         strcat( buf, " : " );
71                         strcat( buf, backends[i].be_suffix[j] );
72                 }
73                 val.bv_val = buf;
74                 val.bv_len = strlen( buf );
75                 attr_merge( e, "database", vals );
76         }
77
78         val.bv_val = "top";
79         val.bv_len = sizeof("top")-1;
80         attr_merge( e, "objectClass", vals );
81
82         val.bv_val = "extenisbleObject";
83         val.bv_len = sizeof("extenisbleObject")-1;
84         attr_merge( e, "objectClass", vals );
85
86         send_search_entry( &backends[0], conn, op, e,
87                 attrs, attrsonly, NULL );
88         send_search_result( conn, op, LDAP_SUCCESS,
89                 NULL, NULL, NULL, NULL, 1 );
90
91         entry_free( e );
92 }
93
94 #endif /* slapd_config_dn */