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