1 /* suffixmassage.c - massages ldap backend dns */
5 * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
6 * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
8 * Module back-ldap, originally developed by Howard Chu
10 * has been modified by Pierangelo Masarati. The original copyright
11 * notice has been maintained.
13 * Permission is granted to anyone to use this software for any purpose
14 * on any computer system, and to alter it and redistribute it, subject
15 * to the following restrictions:
17 * 1. The author is not responsible for the consequences of use of this
18 * software, no matter how awful, even if they arise from flaws in it.
20 * 2. The origin of this software must not be misrepresented, either by
21 * explicit claim or by omission. Since few users ever read sources,
22 * credits should appear in the documentation.
24 * 3. Altered versions must be plainly marked as such, and must not be
25 * misrepresented as being the original software. Since few users
26 * ever read sources, credits should appear in the documentation.
28 * 4. This notice may not be removed or altered.
33 #ifndef ENABLE_REWRITE
37 #include <ac/socket.h>
40 #include "back-ldap.h"
43 * ldap_back_dn_massage
45 * Aliases the suffix; based on suffix_alias (servers/slapd/suffixalias.c).
63 if ( li == NULL || li->suffix_massage == NULL ) {
77 li->suffix_massage[i] != NULL;
79 int aliasLength = li->suffix_massage[i+src]->bv_len;
80 int diff = dn->bv_len - aliasLength;
83 /* alias is longer than dn */
85 } else if ( diff > 0 ) {
86 if ( normalized && ( ! DN_SEPARATOR(dn->bv_val[diff-1]) ) ) {
87 /* boundary is not at a DN separator */
90 /* At a DN Separator */
91 /* XXX or an escaped separator... oh well */
94 if ( !strcmp( li->suffix_massage[i+src]->bv_val, &dn->bv_val[diff] ) ) {
95 res->bv_len = diff + li->suffix_massage[i+dst]->bv_len;
96 res->bv_val = ch_malloc( res->bv_len + 1 );
97 strncpy( res->bv_val, dn->bv_val, diff );
98 strcpy( &res->bv_val[diff], li->suffix_massage[i+dst]->bv_val );
99 Debug( LDAP_DEBUG_ARGS,
100 "ldap_back_dn_massage:"
101 " converted \"%s\" to \"%s\"\n",
102 dn->bv_val, res->bv_val, 0 );
109 #endif /* !ENABLE_REWRITE */