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