1 /* config.c - relay backend configuration file routine */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2003-2004 The OpenLDAP Foundation.
5 * Portions Copyright 2004 Pierangelo Masarati.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masaratifor inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
29 #include "back-relay.h"
41 relay_back_info *ri = (struct relay_back_info *)be->be_private;
44 fprintf( stderr, "%s: line %d: relay backend info is null!\n",
49 /* real naming context */
50 if ( strcasecmp( argv[0], "relay" ) == 0 ) {
51 struct berval dn, ndn, pdn;
56 "%s: line %d: missing relay suffix in \"relay <dn>\" line\n",
61 dn.bv_val = argv[ 1 ];
62 dn.bv_len = strlen( argv[ 1 ] );
63 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
64 if ( rc != LDAP_SUCCESS ) {
65 fprintf( stderr, "%s: line %d: "
66 "relay dn '%s' is invalid\n",
67 fname, lineno, argv[ 1 ] );
71 ri->ri_bd = select_backend( &ndn, 0, 1 );
72 if ( ri->ri_bd == NULL ) {
73 fprintf( stderr, "%s: line %d: "
74 "cannot find database "
76 fname, lineno, argv[ 1 ] );
80 if ( overlay_config( be, "rewrite-remap" ) ) {
81 fprintf( stderr, "unable to install "
82 "rewrite-remap overlay "
83 "in back-relay \"%s\" => \"%s\"\n",
84 be->be_suffix[0].bv_val,
85 ri->ri_bd->be_suffix[0].bv_val ?
86 ri->ri_bd->be_suffix[0].bv_val : "<unknown>" );
91 return SLAP_CONF_UNKNOWN;