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), return an aliased dn if any of the
28 * alias suffixes match
30 char *suffixAlias (char *dn, Operation *op, Backend *be)
34 if(dn == NULL) return NULL;
36 dnLength = strlen ( dn );
38 be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
40 int aliasLength = strlen (be->be_suffixAlias[i]);
41 int diff = dnLength - aliasLength;
44 /* alias is longer than dn */
46 } else if ( diff > 0 ) {
47 if ( ! DNSEPARATOR(dn[diff-1]) ) {
48 /* boundary is not at a DN separator */
51 /* At a DN Separator */
52 /* XXX or an escaped separator... oh well */
55 if (!strcmp(be->be_suffixAlias[i], &dn[diff])) {
57 dn = ch_malloc( diff + strlen(be->be_suffixAlias[i+1]) + 1 );
58 strncpy( dn, oldDN, diff );
59 strcpy( &dn[diff], be->be_suffixAlias[i+1] );
60 Debug( LDAP_DEBUG_ARGS, "SuffixAlias: converted \"%s\" to \"%s\"\n",