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.
26 #include "back-relay.h"
37 relay_back_info *ri = (struct relay_back_info *)be->be_private;
40 fprintf( stderr, "%s: line %d: relay backend info is null!\n",
45 /* real naming context */
46 if ( strcasecmp( argv[0], "relay" ) == 0 ) {
47 struct berval dn, ndn, pdn;
52 "%s: line %d: missing relay suffix in \"relay <dn> [massage]\" line\n",
56 } else if ( argc > 3 ) {
58 "%s: line %d: too many args in \"relay <dn> [massage]\" line\n",
63 dn.bv_val = argv[ 1 ];
64 dn.bv_len = strlen( argv[ 1 ] );
65 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
66 if ( rc != LDAP_SUCCESS ) {
67 fprintf( stderr, "%s: line %d: "
68 "relay dn \"%s\" is invalid\n",
69 fname, lineno, argv[ 1 ] );
73 ri->ri_bd = select_backend( &ndn, 0, 1 );
74 if ( ri->ri_bd == NULL ) {
75 fprintf( stderr, "%s: line %d: "
76 "cannot find database "
77 "of relay dn \"%s\"\n",
78 fname, lineno, argv[ 1 ] );
81 } else if ( ri->ri_bd == be ) {
82 fprintf( stderr, "%s: line %d: "
83 "relay dn \"%s\" would call self\n",
84 fname, lineno, pdn.bv_val );
88 if ( overlay_config( be, "rewrite-remap" ) ) {
89 fprintf( stderr, "%s: line %d: unable to install "
90 "rewrite-remap overlay "
99 if ( strcmp( argv[2], "massage" ) ) {
100 fprintf( stderr, "%s: line %d: "
101 "unknown directive \"%s\" "
102 "in \"relay <dn> [massage]\" line\n",
103 fname, lineno, argv[2] );
107 if ( be->be_suffix[0].bv_val == NULL ) {
108 fprintf( stderr, "%s: line %d: "
109 "relay line must come after \"suffix\"\n",
114 cargv[ 0 ] = "suffixmassage";
115 cargv[ 1 ] = be->be_suffix[0].bv_val;
116 cargv[ 2 ] = ri->ri_bd->be_suffix[0].bv_val;
119 if ( be->be_config( be, "back-relay", 1, 3, cargv ) ) {
126 return SLAP_CONF_UNKNOWN;