]> git.sur5r.net Git - openldap/blob - servers/slapd/configinfo.c
Add OpenLDAP RCSid to *.[ch] in clients, libraries, and servers.
[openldap] / servers / slapd / configinfo.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-1999 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 void
34 config_info(
35         Connection *conn,
36         Operation *op,
37         char **attrs,
38         int attrsonly )
39 {
40         Entry           *e;
41         char            buf[BUFSIZ];
42         struct berval   val;
43         struct berval   *vals[2];
44         int             i, j;
45
46         vals[0] = &val;
47         vals[1] = NULL;
48
49         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
50
51         e->e_attrs = NULL;
52         e->e_dn = ch_strdup( SLAPD_CONFIG_DN );
53         e->e_ndn = ch_strdup( SLAPD_CONFIG_DN );
54         (void) dn_normalize_case( e->e_ndn );
55         e->e_private = NULL;
56
57         {
58                 char *rdn = ch_strdup( SLAPD_CONFIG_DN );
59                 val.bv_val = strchr( rdn, '=' );
60
61                 if( val.bv_val != NULL ) {
62                         *val.bv_val = '\0';
63                         val.bv_len = strlen( ++val.bv_val );
64
65                         attr_merge( e, rdn, vals );
66                 }
67
68                 free( rdn );
69         }
70
71         for ( i = 0; i < nbackends; i++ ) {
72                 strcpy( buf, backends[i].be_type );
73                 for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
74                         strcat( buf, " : " );
75                         strcat( buf, backends[i].be_suffix[j] );
76                 }
77                 val.bv_val = buf;
78                 val.bv_len = strlen( buf );
79                 attr_merge( e, "database", vals );
80         }
81
82         val.bv_val = "top";
83         val.bv_len = sizeof("top")-1;
84         attr_merge( e, "objectClass", vals );
85
86         val.bv_val = "LDAPsubentry";
87         val.bv_len = sizeof("LDAPsubentry")-1;
88         attr_merge( e, "objectClass", vals );
89
90         val.bv_val = "extensibleObject";
91         val.bv_len = sizeof("extensibleObject")-1;
92         attr_merge( e, "objectClass", vals );
93
94         send_search_entry( &backends[0], conn, op, e,
95                 attrs, attrsonly, NULL );
96         send_search_result( conn, op, LDAP_SUCCESS,
97                 NULL, NULL, NULL, NULL, 1 );
98
99         entry_free( e );
100 }
101
102 #endif /* slapd_config_dn */