From a609b53233a0bf0f0c16057c6110b8bff427d926 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Mon, 9 Jan 2017 10:51:06 +0100
Subject: [PATCH] Fixes #5296 Using system cn in the dhcp cn after migration in
 fusiondirectory-setup

---
 contrib/bin/fusiondirectory-setup | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 22a515a1d..256636990 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -1454,16 +1454,17 @@ sub migrate_dhcp {
   } else {
     if (ask_yn_question("Move these entries to the DHCP branch ($dhcprdn)?")) {
       foreach my $entrydn (@baddns) {
-        $entrydn =~ m/^([^,]+),(.+$systemrdn,(.+))$/ or die "Could not parse dn ".$entrydn."\n";
+        $entrydn =~ m/^([^,]+),(cn=(.+),$systemrdn,(.+))$/ or die "Could not parse dn ".$entrydn."\n";
         my $rdn = $1;
         my $systemdn = $2;
-        my $entrybase = $3;
+        my $systemcn = $3;
+        my $entrybase = $4;
         if (!branch_exists($ldap, "$dhcprdn,$entrybase")) {
           create_branch($ldap, $entrybase, $dhcprdn);
         }
         my $result = $ldap->moddn (
           $entrydn,
-          newrdn        => $rdn,
+          newrdn        => "$rdn-$systemcn",
           deleteoldrdn  => '1',
           newsuperior   => "$dhcprdn,$entrybase"
         );
-- 
GitLab