From 722fe6f394acc2bca7981743b3d05817dc95ea15 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Mon, 23 Jan 2012 11:30:11 -0800
Subject: [PATCH] Trac Ticket 139 - eliminate the use of char *dn in favor of
 Slapi_DN *dn

https://fedorahosted.org/389/ticket/139

Fix description: The oritinal RFE had been already implemented in
the commit f6397113666f06848412bb12f754f04258cfa5fa:
    Reduce the number of DN normalization
In this patch, the Slapi_DN creation (slapi_sdn_{new,set,init}_dn_*)
are replaced with corresponding _normdn_ or _ndn_ APIs which takes
advantage of the knowledge that the DN is already optimized or not.
---
 ldap/servers/plugins/acctpolicy/acct_config.c    |    2 +-
 ldap/servers/plugins/acctpolicy/acct_plugin.c    |    2 +-
 ldap/servers/plugins/acl/acleffectiverights.c    |    2 +-
 ldap/servers/plugins/acl/aclinit.c               |    2 +-
 ldap/servers/plugins/automember/automember.c     |    6 ++--
 ldap/servers/plugins/dna/dna.c                   |   15 +++++---
 ldap/servers/plugins/linkedattrs/fixup_task.c    |    4 +-
 ldap/servers/plugins/linkedattrs/linked_attrs.c  |    2 +-
 ldap/servers/plugins/memberof/memberof.c         |   38 +++++++++++-----------
 ldap/servers/plugins/mep/mep.c                   |   12 +++---
 ldap/servers/plugins/referint/referint.c         |    4 +-
 ldap/servers/plugins/replication/repl5_replica.c |    2 +-
 ldap/servers/slapd/config.c                      |    2 +-
 ldap/servers/slapd/dn.c                          |    2 +-
 ldap/servers/slapd/fedse.c                       |   14 ++++----
 ldap/servers/slapd/main.c                        |    2 +-
 ldap/servers/slapd/mapping_tree.c                |    6 ++--
 ldap/servers/slapd/plugin.c                      |    4 +-
 ldap/servers/slapd/plugin_internal_op.c          |    4 +-
 ldap/servers/slapd/schema.c                      |    2 +-
 ldap/servers/slapd/snmp_collator.c               |    2 +-
 21 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/ldap/servers/plugins/acctpolicy/acct_config.c b/ldap/servers/plugins/acctpolicy/acct_config.c
index 5d462a3..3da338a 100644
--- a/ldap/servers/plugins/acctpolicy/acct_config.c
+++ b/ldap/servers/plugins/acctpolicy/acct_config.c
@@ -42,7 +42,7 @@ acct_policy_load_config_startup( Slapi_PBlock* pb, void* plugin_id ) {
 	int rc;
 
 	/* Retrieve the config entry */
-	config_sdn = slapi_sdn_new_dn_byref( PLUGIN_CONFIG_DN );
+	config_sdn = slapi_sdn_new_normdn_byref( PLUGIN_CONFIG_DN );
 	rc = slapi_search_internal_get_entry( config_sdn, NULL, &config_entry,
 		plugin_id);
 	slapi_sdn_free( &config_sdn );
diff --git a/ldap/servers/plugins/acctpolicy/acct_plugin.c b/ldap/servers/plugins/acctpolicy/acct_plugin.c
index 9c74278..975b7c7 100644
--- a/ldap/servers/plugins/acctpolicy/acct_plugin.c
+++ b/ldap/servers/plugins/acctpolicy/acct_plugin.c
@@ -274,7 +274,7 @@ acct_bind_postop( Slapi_PBlock *pb )
 	/* We're not always tracking logins, so check whether the entry is
 	   covered by an account policy to decide whether we should track */
 	if( tracklogin == 0 ) {
-		sdn = slapi_sdn_new_dn_byref( dn );
+		sdn = slapi_sdn_new_normdn_byref( dn );
 		ldrc = slapi_search_internal_get_entry_ext( sdn, NULL, &target_entry,
 			plugin_id, txn );
 
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index 3d1f754..380dd74 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -376,7 +376,7 @@ _ger_new_gerpb (
 		 */
 		gerop->o_extension = factory_create_extension ( get_operation_object_type(), (void *)gerop, (void *)conn );
 		slapi_pblock_set ( *gerpb, SLAPI_OPERATION, gerop );
-		slapi_sdn_set_dn_byval ( &gerop->o_sdn, subjectndn );
+		slapi_sdn_set_ndn_byval ( &gerop->o_sdn, subjectndn );
 		geraclpb = acl_get_ext ( ACL_EXT_OPERATION, (void *)gerop);
 		acl_init_aclpb ( *gerpb, geraclpb, subjectndn, 0 );
 		geraclpb->aclpb_res_type |= ACLPB_EFFECTIVE_RIGHTS;
diff --git a/ldap/servers/plugins/acl/aclinit.c b/ldap/servers/plugins/acl/aclinit.c
index e99e57f..9628075 100644
--- a/ldap/servers/plugins/acl/aclinit.c
+++ b/ldap/servers/plugins/acl/aclinit.c
@@ -156,7 +156,7 @@ aclinit_main()
 	 * rootdse entry so we search for acis in there explicitly here.
 	*/
 
-	sdn = slapi_sdn_new_dn_byval("");
+	sdn = slapi_sdn_new_ndn_byval("");
 	slapi_log_error ( SLAPI_LOG_ACL, plugin_name,
 				"Searching for all acis(scope base) at suffix ''\n");
 	aclinit_search_and_update_aci ( 0,		/* thisbeonly */
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index c5e5667..92d5ae6 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -349,7 +349,7 @@ automember_start(Slapi_PBlock * pb)
     /* Set the alternate config area if one is defined. */
     slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area);
     if (config_area) {
-        automember_set_config_area(slapi_sdn_new_dn_byval(config_area));
+        automember_set_config_area(slapi_sdn_new_normdn_byval(config_area));
     }
 
     /*
@@ -1025,7 +1025,7 @@ automember_parse_regex_entry(struct configEntry *config, Slapi_Entry *e)
 
             if (rule) {
                 /* Fill in the target group. */
-                rule->target_group_dn = slapi_sdn_new_dn_byval(target_group);
+                rule->target_group_dn = slapi_sdn_new_normdn_byval(target_group);
 
                 if (!PR_CLIST_IS_EMPTY((PRCList *)config->inclusive_rules)) {
                     list = PR_LIST_HEAD((PRCList *)config->inclusive_rules);
@@ -1079,7 +1079,7 @@ automember_parse_regex_entry(struct configEntry *config, Slapi_Entry *e)
 
             if (rule) { 
                 /* Fill in the target group. */
-                rule->target_group_dn = slapi_sdn_new_dn_byval(target_group);
+                rule->target_group_dn = slapi_sdn_new_normdn_byval(target_group);
 
                 if (!PR_CLIST_IS_EMPTY((PRCList *)config->exclusive_rules)) {
                     list = PR_LIST_HEAD((PRCList *)config->exclusive_rules);
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 2c7876f..a422055 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1236,7 +1236,7 @@ dna_load_host_port()
     attrs[2] = "nsslapd-secureport";
     attrs[3] = NULL;
 
-    config_dn = slapi_sdn_new_dn_byref("cn=config");
+    config_dn = slapi_sdn_new_ndn_byref("cn=config");
     if (config_dn) {
         slapi_search_internal_get_entry(config_dn, attrs, &e, getPluginID());
         slapi_sdn_free(&config_dn);
@@ -1506,7 +1506,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers, void
         Slapi_DN *cfg_sdn = NULL;
         int i;
 
-        cfg_sdn = slapi_sdn_new_dn_byref(config_entry->shared_cfg_dn);
+        cfg_sdn = slapi_sdn_new_normdn_byref(config_entry->shared_cfg_dn);
 
         /* We found some entries.  Go through them and
          * order them based off of remaining values. */
@@ -2206,11 +2206,14 @@ dna_update_shared_config(struct configEntry * config_entry, void *txn)
              * already exist, we add it. */
             if (ret == LDAP_NO_SUCH_OBJECT) {
                 Slapi_Entry *e = NULL;
+                Slapi_DN *sdn = 
+                        slapi_sdn_new_normdn_byref(config_entry->shared_cfg_dn);
 
                 /* Set up the new shared config entry */
                 e = slapi_entry_alloc();
                 /* the entry now owns the dup'd dn */
-                slapi_entry_init(e, slapi_ch_strdup(config_entry->shared_cfg_dn), NULL);
+                slapi_entry_init_ext(e, sdn, NULL); /* sdn is copied into e */
+                slapi_sdn_free(&sdn);
 
                 slapi_entry_add_string(e, SLAPI_ATTR_OBJECTCLASS, "extensibleObject");
                 slapi_entry_add_string(e, DNA_HOSTNAME, hostname);
@@ -2434,7 +2437,7 @@ static int dna_is_replica_bind_dn(char *range_dn, char *bind_dn)
             ret = 1;
             goto done;
         }
-        replica_sdn = slapi_sdn_new_dn_passin(replica_dn);
+        replica_sdn = slapi_sdn_new_normdn_passin(replica_dn);
 
         attrs[0] = DNA_REPL_BIND_DN;
         attrs[1] = 0;
@@ -2479,7 +2482,7 @@ static int dna_get_replica_bind_creds(char *range_dn, struct dnaServer *server,
     int ret = LDAP_OPERATIONS_ERROR;
 
     /* Find the backend suffix where the shared config is stored. */
-    range_sdn = slapi_sdn_new_dn_byref(range_dn);
+    range_sdn = slapi_sdn_new_normdn_byref(range_dn);
     if ((be = slapi_be_select(range_sdn)) != NULL) {
         be_suffix = slapi_sdn_get_dn(slapi_be_getsuffix(be, 0));
     }
@@ -3398,7 +3401,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
             list = PR_LIST_HEAD(dna_global_config);
             while ((list != dna_global_config) && match != 1) {
                 config_entry = (struct configEntry *)list;
-                cfg_base_sdn = slapi_sdn_new_dn_byref(config_entry->shared_cfg_base);
+                cfg_base_sdn = slapi_sdn_new_normdn_byref(config_entry->shared_cfg_base);
                 
                 if (slapi_sdn_compare(cfg_base_sdn, range_sdn) == 0) {
                     /* We found a match.  Set match flag to
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c b/ldap/servers/plugins/linkedattrs/fixup_task.c
index a698a6c..b92c6b7 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -369,7 +369,7 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data)
     for (i = 0; targets && targets[i]; ++i) {
         char *targetdn = (char *)targets[i];
         int perform_update = 0;
-        Slapi_DN *targetsdn = slapi_sdn_new_dn_byref(targetdn);
+        Slapi_DN *targetsdn = slapi_sdn_new_normdn_byref(targetdn);
 
         if (g_get_shutdown()) {
             return -1;
@@ -382,7 +382,7 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data)
             /* Find out the root suffix that the linkdn is in
              * and see if the target is in the same backend. */
             Slapi_Backend *be = NULL;
-            Slapi_DN *linksdn = slapi_sdn_new_dn_byref(linkdn);
+            Slapi_DN *linksdn = slapi_sdn_new_normdn_byref(linkdn);
 
             if ((be = slapi_be_select(linksdn))) {
                 perform_update = slapi_sdn_issuffix(targetsdn, slapi_be_getsuffix(be, 0));
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 1a647bc..c00c896 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1472,7 +1472,7 @@ linked_attrs_mod_backpointers(char *linkdn, char *type,
             perform_update = slapi_dn_issuffix(targetdn, scope);
         } else {
             Slapi_Backend *be = NULL;
-            Slapi_DN *linksdn = slapi_sdn_new_dn_byref(linkdn);
+            Slapi_DN *linksdn = slapi_sdn_new_normdn_byref(linkdn);
 
             if ((be = slapi_be_select(linksdn))) {
                 perform_update = slapi_sdn_issuffix(targetsdn, slapi_be_getsuffix(be, 0));
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index 19c3085..5100b1a 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -382,7 +382,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
 {
 	int ret = 0;
 	MemberOfConfig configCopy = {0, 0, 0, 0};
-	char *dn;
+	char *normdn;
 	void *caller_id = NULL;
 
 	slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -396,7 +396,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
 		return 0;
 	}
 
-	if(memberof_oktodo(pb) && (dn = memberof_getdn(pb)))
+	if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb)))
 	{
 		struct slapi_entry *e = NULL;
 		void *txn = NULL;
@@ -418,7 +418,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
 		/* remove this DN from the
 		 * membership lists of groups
 		 */
-		memberof_del_dn_from_groups(pb, &configCopy, dn, txn);
+		memberof_del_dn_from_groups(pb, &configCopy, normdn, txn);
 
 		/* is the entry of interest as a group? */
 		if(e && configCopy.group_filter && !slapi_filter_test_simple(e, configCopy.group_filter))
@@ -431,7 +431,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
 			{
 				if (0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr))
 				{
-					memberof_del_attr_list(pb, &configCopy, dn, attr, txn);
+					memberof_del_attr_list(pb, &configCopy, normdn, attr, txn);
 				}
 			}
 		}
@@ -536,7 +536,7 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, char *dn,
 	   (we don't support having members and groups in
            different backends - issues with offline / read only backends)
 	*/
-	sdn = slapi_sdn_new_dn_byref(dn);
+	sdn = slapi_sdn_new_normdn_byref(dn);
 	be = slapi_be_select(sdn);
 	if(be)
 	{
@@ -789,7 +789,7 @@ int memberof_replace_dn_type_callback(Slapi_Entry *e, void *callback_data)
 int memberof_postop_modify(Slapi_PBlock *pb)
 {
 	int ret = 0;
-	char *dn = 0;
+	char *normdn = 0;
 	Slapi_Mods *smods = 0;
 	Slapi_Mod *smod = 0;
 	LDAPMod **mods;
@@ -807,8 +807,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
 		return 0;
 	}
 
-	if(memberof_oktodo(pb) &&
-		(dn = memberof_getdn(pb)))
+	if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb)))
 	{
 		int config_copied = 0;
 		MemberOfConfig *mainConfig = 0;
@@ -866,7 +865,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
 				case LDAP_MOD_ADD:
 					{
 						/* add group DN to targets */
-						memberof_add_smod_list(pb, &configCopy, dn, smod, txn);
+						memberof_add_smod_list(pb, &configCopy, normdn, smod, txn);
 						break;
 					}
 				
@@ -878,12 +877,12 @@ int memberof_postop_modify(Slapi_PBlock *pb)
 						 * entry, which the replace code deals with. */
 						if (slapi_mod_get_num_values(smod) == 0)
 						{
-							memberof_replace_list(pb, &configCopy, dn, txn);
+							memberof_replace_list(pb, &configCopy, normdn, txn);
 						}
 						else
 						{
 							/* remove group DN from target values in smod*/
-							memberof_del_smod_list(pb, &configCopy, dn, smod, txn);
+							memberof_del_smod_list(pb, &configCopy, normdn, smod, txn);
 						}
 						break;
 					}
@@ -891,7 +890,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
 				case LDAP_MOD_REPLACE:
 					{
 						/* replace current values */
-						memberof_replace_list(pb, &configCopy, dn, txn);
+						memberof_replace_list(pb, &configCopy, normdn, txn);
 						break;
 					}
 
@@ -937,7 +936,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
 {
 	int ret = 0;
 	int interested = 0;
-	char *dn = 0;
+	char *normdn = 0;
 	void *caller_id = NULL;
 
 	slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -951,7 +950,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
 		return 0;
 	}
 
-	if(memberof_oktodo(pb) && (dn = memberof_getdn(pb)))
+	if(memberof_oktodo(pb) && (normdn = memberof_getdn(pb)))
 	{
 		MemberOfConfig *mainConfig = 0;
 		MemberOfConfig configCopy = {0, 0, 0, 0};
@@ -984,7 +983,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
 			{
 				if(0 == slapi_entry_attr_find(e, configCopy.groupattrs[i], &attr))
 				{
-					memberof_add_attr_list(pb, &configCopy, dn, attr, txn);
+					memberof_add_attr_list(pb, &configCopy, normdn, attr, txn);
 				}
 			}
 
@@ -1049,6 +1048,7 @@ bail:
  * memberof_getdn()
  *
  * Get dn of target entry
+ * Note: slapi_sdn_get_dn returns normalized dn.
  *
  */
 char *memberof_getdn(Slapi_PBlock *pb)
@@ -1057,7 +1057,7 @@ char *memberof_getdn(Slapi_PBlock *pb)
 	Slapi_DN *sdn = NULL;
 
 	slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn);
-	dn = slapi_sdn_get_dn(sdn);	
+	dn = slapi_sdn_get_dn(sdn); /* returns norm dn */
 
 	return (char *)dn;
 }
@@ -1124,7 +1124,7 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
 	}
 
 	/* determine if this is a group op or single entry */
-	op_to_sdn = slapi_sdn_new_dn_byref(op_to);
+	op_to_sdn = slapi_sdn_new_normdn_byref(op_to);
 	slapi_search_internal_get_entry_ext( op_to_sdn, config->groupattrs,
 		&e, memberof_get_plugin_id(), txn);
 	if(!e)
@@ -1157,7 +1157,7 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
 			if(base_sdn)
 			{
 				filter_str = slapi_ch_smprintf("(%s=%s)",
-				config->memberof_attr, op_to);
+				                               config->memberof_attr, op_to);
 			}
 
 			if(filter_str)
@@ -1748,7 +1748,7 @@ int memberof_is_direct_member(MemberOfConfig *config, Slapi_Value *groupdn,
 	Slapi_Attr *attr = 0;
 	int i = 0;
 
-	sdn = slapi_sdn_new_dn_byref(slapi_value_get_string(groupdn));
+	sdn = slapi_sdn_new_normdn_byref(slapi_value_get_string(groupdn));
 
 	slapi_search_internal_get_entry_ext(sdn, config->groupattrs,
 		&group_e, memberof_get_plugin_id(), txn);
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index 47a6daf..303d9b3 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -365,7 +365,7 @@ mep_start(Slapi_PBlock * pb)
     /* Set the alternate config area if one is defined. */
     slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area);
     if (config_area) {
-        mep_set_config_area(slapi_sdn_new_dn_byval(config_area));
+        mep_set_config_area(slapi_sdn_new_normdn_byval(config_area));
     }
 
     /*
@@ -2182,7 +2182,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
                     /* Fetch the origin entry so we can locate the config template. */
                     origin_dn = slapi_entry_attr_get_charptr(e, MEP_MANAGED_BY_TYPE);
                     if (origin_dn) {
-                        origin_sdn = slapi_sdn_new_dn_byref(origin_dn);
+                        origin_sdn = slapi_sdn_new_normdn_byref(origin_dn);
                         slapi_search_internal_get_entry_ext(origin_sdn, 0,
                                 &origin_e, mep_get_plugin_id(), txn);
                         slapi_sdn_free(&origin_sdn);
@@ -2419,8 +2419,8 @@ mep_mod_post_op(Slapi_PBlock *pb)
 
                 /* Check if we need to rename the managed entry. */
                 if (mapped_dn) {
-                    mapped_sdn = slapi_sdn_new_dn_passin(mapped_dn);
-                    managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
+                    mapped_sdn = slapi_sdn_new_normdn_passin(mapped_dn);
+                    managed_sdn = slapi_sdn_new_normdn_byref(managed_dn);
 
                     if (slapi_sdn_compare(managed_sdn, mapped_sdn) != 0) {
                         mep_rename_managed_entry(e, mapped_sdn, managed_sdn, txn);
@@ -2739,14 +2739,14 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
              * it has already been renamed by another plug-in.  If it
              * has already been renamed, we need to use the new DN to
              * perform our updates. */
-            managed_sdn = slapi_sdn_new_dn_byref(managed_dn);
+            managed_sdn = slapi_sdn_new_normdn_byref(managed_dn);
 
             if (slapi_search_internal_get_entry_ext(managed_sdn, 0,
                     NULL, mep_get_plugin_id(), txn) == LDAP_NO_SUCH_OBJECT) {
                 slapi_ch_free_string(&managed_dn);
                 /* This DN is not a copy, so we don't want to free it later. */
                 managed_dn = slapi_entry_get_dn(new_managed_entry);
-                slapi_sdn_set_dn_byref(managed_sdn, managed_dn);
+                slapi_sdn_set_normdn_byref(managed_sdn, managed_dn);
                 free_managed_dn = 0;
             }
 
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 9c655ca..195ff2b 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -971,7 +971,7 @@ referint_thread_func(void *arg)
   
 	while( GetNextLine(thisline, MAX_LINE, prfd) ){
 	    ptoken = ldap_utf8strtok_r(thisline, delimiter, &iter);
-		sdn = slapi_sdn_new_dn_byref(ptoken);
+		sdn = slapi_sdn_new_normdn_byref(ptoken);
 
 	    ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
 	    if(!strcasecmp(ptoken, "NULL")) {
@@ -984,7 +984,7 @@ referint_thread_func(void *arg)
 	    if (!strcasecmp(ptoken, "NULL")) {
 	        tmpsuperior = NULL;
 	    } else {
-	        tmpsuperior = slapi_sdn_new_dn_byref(ptoken);
+	        tmpsuperior = slapi_sdn_new_normdn_byref(ptoken);
 	    }
       
 	    update_integrity(plugin_argv, sdn, tmprdn,
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 08c6509..8c7a2ab 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -3132,7 +3132,7 @@ replica_log_ruv_elements_nolock (const Replica *r)
            special target dn */
         memset (&op_params, 0, sizeof (op_params));
         op_params.operation_type = SLAPI_OPERATION_DELETE;
-        op_params.target_address.sdn = slapi_sdn_new_dn_byval(START_ITERATION_ENTRY_DN);
+        op_params.target_address.sdn = slapi_sdn_new_ndn_byval(START_ITERATION_ENTRY_DN);
         op_params.target_address.uniqueid = START_ITERATION_ENTRY_UNIQUEID;
         op_params.csn = csn;
         repl_gen = ruv_get_replica_generation (ruv);
diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c
index c25438d..f1df7ba 100644
--- a/ldap/servers/slapd/config.c
+++ b/ldap/servers/slapd/config.c
@@ -250,7 +250,7 @@ slapd_bootstrap_config(const char *configdir)
 			dn_validate_strict[0] = '\0';
 
 			/* Convert LDIF to entry structures */
-			slapi_sdn_init_dn_byref(&plug_dn, PLUGIN_BASE_DN);
+			slapi_sdn_init_ndn_byref(&plug_dn, PLUGIN_BASE_DN);
 			while ((entrystr = dse_read_next_entry(buf, &lastp)) != NULL)
 			{
 				char errorbuf[BUFSIZ];
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index f434526..aeb24b3 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2307,7 +2307,7 @@ slapi_sdn_get_parent_ext(const Slapi_DN *sdn,
 {
     const char *parentdn =
                        slapi_dn_parent_ext(slapi_sdn_get_dn(sdn), is_tombstone);
-    slapi_sdn_set_dn_passin(sdn_parent,parentdn);
+    slapi_sdn_set_normdn_passin(sdn_parent,parentdn);
     sdn_parent->flag= slapi_setbit_uchar(sdn_parent->flag,FLAG_DN);
     PR_INCREMENT_COUNTER(slapi_sdn_counter_dn_created);
     PR_INCREMENT_COUNTER(slapi_sdn_counter_dn_exist);
diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c
index ab94628..dbfba16 100644
--- a/ldap/servers/slapd/fedse.c
+++ b/ldap/servers/slapd/fedse.c
@@ -1770,7 +1770,7 @@ setup_internal_backends(char *configdir)
     int rc = init_schema_dse(configdir);
 	Slapi_DN config;
 
-	slapi_sdn_init_dn_byref(&config,"cn=config");
+	slapi_sdn_init_ndn_byref(&config,"cn=config");
 
 	if (rc)
 	{
@@ -1787,13 +1787,13 @@ setup_internal_backends(char *configdir)
         Slapi_DN encryption;
         Slapi_DN saslmapping;
 
-		slapi_sdn_init_dn_byref(&monitor,"cn=monitor");
-		slapi_sdn_init_dn_byref(&counters,"cn=counters,cn=monitor");
-		slapi_sdn_init_dn_byref(&snmp,"cn=snmp,cn=monitor");
-		slapi_sdn_init_dn_byref(&root,"");
+		slapi_sdn_init_ndn_byref(&monitor,"cn=monitor");
+		slapi_sdn_init_ndn_byref(&counters,"cn=counters,cn=monitor");
+		slapi_sdn_init_ndn_byref(&snmp,"cn=snmp,cn=monitor");
+		slapi_sdn_init_ndn_byref(&root,"");
 
-		slapi_sdn_init_dn_byref(&encryption,"cn=encryption,cn=config");
-		slapi_sdn_init_dn_byref(&saslmapping,"cn=mapping,cn=sasl,cn=config");
+		slapi_sdn_init_ndn_byref(&encryption,"cn=encryption,cn=config");
+		slapi_sdn_init_ndn_byref(&saslmapping,"cn=mapping,cn=sasl,cn=config");
 
         /* Search */
     	dse_register_callback(pfedse,SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,&config,LDAP_SCOPE_BASE,"(objectclass=*)",read_config_dse,NULL);
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index ffcdbab..3455852 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1116,7 +1116,7 @@ main( int argc, char **argv)
 		/* initialize UniqueID generator - must be done once backends are started
 		   and event queue is initialized but before plugins are started */
 		/* Note: This DN is no need to be normalized. */
-		sdn = slapi_sdn_new_dn_byval ("cn=uniqueid generator,cn=config");
+		sdn = slapi_sdn_new_ndn_byval ("cn=uniqueid generator,cn=config");
 		rc = uniqueIDGenInit (NULL, sdn, slapd_exemode == SLAPD_EXEMODE_SLAPD);
 		slapi_sdn_free (&sdn);
 		if (rc != UID_SUCCESS)
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 3aa3bec..b2db9fe 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -387,7 +387,7 @@ get_parent_from_entry(Slapi_Entry * entry)
                 *ptr = '\0';
             }
         }
-        parent_sdn = slapi_sdn_new_dn_passin(slapi_ch_smprintf("%s", parent));
+        parent_sdn = slapi_sdn_new_dn_byval(parent);
         slapi_ch_free_string(&origparent);
     }
     
@@ -433,7 +433,7 @@ get_subtree_from_entry(Slapi_Entry * entry)
                 *ptr = '\0';
             }
         }
-        subtree = slapi_sdn_new_dn_passin(slapi_ch_smprintf("%s", cn));
+        subtree = slapi_sdn_new_dn_byval(cn);
         slapi_ch_free_string(&origcn);
     }
     
@@ -2946,7 +2946,7 @@ slapi_get_mapping_tree_node_configsdn (const Slapi_DN *root)
         return NULL;
     }
 
-    sdn = slapi_sdn_new_dn_passin(dn);
+    sdn = slapi_sdn_new_normdn_passin(dn);
 
     return sdn;
 }
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 50df502..4c8e8bd 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -271,7 +271,7 @@ slapi_register_plugin_ext(
     int rc = 0;
 	Slapi_Entry *e = NULL;
 	char *dn = slapi_ch_smprintf("cn=%s,%s", name, PLUGIN_BASE_DN);
-	Slapi_DN *sdn = slapi_sdn_new_dn_passin(dn);
+	Slapi_DN *sdn = slapi_sdn_new_normdn_passin(dn);
 
 	e = slapi_entry_alloc();
 	/* this function consumes dn */
@@ -1947,7 +1947,7 @@ plugin_add_descriptive_attributes( Slapi_Entry *e, struct slapdplugin *plugin )
 			for ( plugtmp = global_plugin_list[i]; NULL == plugin && plugtmp;
 						plugtmp = plugtmp->plg_next)
 			{
-				slapi_sdn_init_dn_byref( &pdn, plugtmp->plg_dn );
+				slapi_sdn_init_normdn_byref( &pdn, plugtmp->plg_dn );
 				if ( 0 == slapi_sdn_compare( &pdn, ednp ))
 				{
 					plugin = plugtmp;
diff --git a/ldap/servers/slapd/plugin_internal_op.c b/ldap/servers/slapd/plugin_internal_op.c
index 563bc46..9654780 100644
--- a/ldap/servers/slapd/plugin_internal_op.c
+++ b/ldap/servers/slapd/plugin_internal_op.c
@@ -388,7 +388,7 @@ static int seq_internal_callback_pb (Slapi_PBlock *pb, void *callback_data,
 	slapi_pblock_get(pb, SLAPI_CONTROLS_ARG, &controls);
 
 	if (base == NULL) {
-		sdn = slapi_sdn_new_dn_byval("");
+		sdn = slapi_sdn_new_ndn_byval("");
 	} else {
 		sdn = slapi_sdn_new_dn_byref(base);
 	}
@@ -837,7 +837,7 @@ PRBool allow_operation (Slapi_PBlock *pb)
 	slapi_sdn_init(&sdn);
 	slapi_pblock_get (pb, SLAPI_TARGET_SDN, &sdnp);
 	if (NULL == sdnp) {
-		slapi_sdn_init_dn_byval(&sdn,"");
+		slapi_sdn_init_ndn_byval(&sdn,"");
 		sdnp = &sdn;
 	}
 
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 03f8b95..f5bc0c2 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -4034,7 +4034,7 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
 	}
 
 	*local_pschemadse = NULL;
-	slapi_sdn_init_dn_byref(&schema,"cn=schema");
+	slapi_sdn_init_ndn_byref(&schema,"cn=schema");
 
 	/* get schemadir if not given */
 	if (NULL == schemadir)
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index 6a059b9..aeac7ae 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -887,7 +887,7 @@ getConfigEntry( Slapi_Entry **e ) {
         Slapi_DN        sdn;
 
         /* SNMP_CONFIG_DN: no need to be normalized */
-        slapi_sdn_init_dn_byref( &sdn, SNMP_CONFIG_DN );
+        slapi_sdn_init_normdn_byref( &sdn, SNMP_CONFIG_DN );
         slapi_search_internal_get_entry( &sdn, NULL, e,
                         plugin_get_default_component_id());
         slapi_sdn_done( &sdn );
-- 
1.7.6.4

