3 * Copyright 1999-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file in the top level
6 * directory of this package.
9 * Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
10 * All rights reserved.
12 * Redistribution and use in source and binary forms are permitted
13 * provided that this notice is preserved and that due credit is given
14 * to ITSD, Government of BC. The name of ITSD
15 * may not be used to endorse or promote products derived from this
16 * software without specific prior written permission. This software
17 * is provided ``as is'' without express or implied warranty.
23 #include <ac/string.h>
24 #include <ac/socket.h>
28 * given a normalized uppercased dn (or root part),
29 * return an aliased dn if any of the alias suffixes match
37 if(dn == NULL) return NULL;
38 if(be == NULL) return dn;
40 dnLength = strlen ( dn );
43 be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
46 int aliasLength = strlen (be->be_suffixAlias[i]);
47 int diff = dnLength - aliasLength;
50 /* alias is longer than dn */
52 } else if ( diff > 0 ) {
53 if ( ! DN_SEPARATOR(dn[diff-1]) ) {
54 /* boundary is not at a DN separator */
57 /* At a DN Separator */
58 /* XXX or an escaped separator... oh well */
61 if (!strcmp(be->be_suffixAlias[i], &dn[diff])) {
63 dn = ch_malloc( diff + strlen(be->be_suffixAlias[i+1]) + 1 );
64 strncpy( dn, oldDN, diff );
65 strcpy( &dn[diff], be->be_suffixAlias[i+1] );
66 Debug( LDAP_DEBUG_ARGS,
67 "suffix_alias: converted \"%s\" to \"%s\"\n",