From 59c29815139513d65be292a3735c71945f6abebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Wed, 24 May 2017 12:02:13 +0200 Subject: [PATCH] =?UTF-8?q?Fixes=20#5538=20Fixed=20parsing=20of=20winstati?= =?UTF-8?q?on=20DN=20when=20it=E2=80=99s=20not=20in=20systems=20RDN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/bin/fusiondirectory-setup | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup index 899efd54f..2e305724c 100644 --- a/contrib/bin/fusiondirectory-setup +++ b/contrib/bin/fusiondirectory-setup @@ -95,6 +95,7 @@ my $systemrdn = "ou=systems"; my $dnsrdn = "ou=dns"; my $dhcprdn = "ou=dhcp"; my $workstationrdn = "ou=workstations,ou=systems"; +my $winstationrdn = "ou=computers,ou=systems"; ################################################################################################################################################# @@ -1486,8 +1487,16 @@ sub migrate_winstations $entry->replace('cn' => $cn); my $newrdn = "cn=".$cn; my $dn_old = $entry->dn(); - $dn_old =~ m/^[^,]+,.*$systemrdn,(.+)$/ or die "Could not parse dn ".$dn_old."\n"; - my $entrybase = $1; + my $entrybase; + if ($dn_old =~ m/^[^,]+,$winstationrdn,(.+)$/) { + $entrybase = $1; + } elsif ($dn_old =~ m/^[^,]+,.*$systemrdn,(.+)$/) { + $entrybase = $1; + } elsif ($dn_old =~ m/^[^,]+,.*$winstationrdn,(.+)$/) { + $entrybase = $1; + } else { + die "Could not parse dn ".$dn_old."\n"; + } if (!branch_exists($ldap, "$workstationrdn,$entrybase")) { if ($workstationrdn =~ m/^([^,]+),([^,]+)$/) { if (!branch_exists($ldap, "$2,$entrybase")) { @@ -1737,6 +1746,9 @@ sub read_ldap_config { if (($mesg->entries)[0]->exists('fdWorkstationRDN')) { $workstationrdn = ($mesg->entries)[0]->get_value('fdWorkstationRDN'); } + if (($mesg->entries)[0]->exists('fdSambaMachineAccountRDN')) { + $winstationrdn = ($mesg->entries)[0]->get_value('fdSambaMachineAccountRDN'); + } } return ($mesg->entries)[0]; -- GitLab