diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup index 105b7792825502ed38d5f8a6d078cac3adfcdae9..d8ba7c1bcdb0c49c2fe1412aa46f036b12bd03a1 100644 --- a/contrib/bin/fusiondirectory-setup +++ b/contrib/bin/fusiondirectory-setup @@ -1610,6 +1610,47 @@ sub migrate_phones { $unbind->code && warn "! Unable to unbind from LDAP server: ", $unbind->error."\n"; } +# function that migrates supannTypeEntite from FD<1.3 to FD>=1.3 +sub migrate_supanntypeentite { + # initiate the LDAP connexion + my %hash_ldap_param = get_ldap_connexion(); + + # LDAP's connection's parameters + my $base = $hash_ldap_param{base}; + my $ldap = $hash_ldap_param{ldap}; + + my $mesg = $ldap->search( + filter => '(&(supannTypeEntite=*)(!(supannTypeEntite={*}*)))', + base => $base + ); + $mesg->code && die $mesg->error; + + if ($mesg->count > 0) { + print ("The following entries are missing prefix in supannTypeEntite value:\n"); + + my @entries = $mesg->entries; + + foreach my $entry (@entries) { + print $entry->dn().": ".$entry->get_value("supannTypeEntite")."\n"; + } + + if (ask_yn_question("Migrate these entries to add the {SUPANN} prefix?")) { + foreach my $entry (@entries) { + $entry->replace("supannTypeEntite" => "{SUPANN}".$entry->get_value("supannTypeEntite")); + $mesg = $entry->update($ldap); + if ($mesg->code) { + print $entry->dn().": ".$mesg->error."\n"; + next; + } + } + } + } + + # unbind to the LDAP server + my $unbind = $ldap->unbind; + $unbind->code && warn "! Unable to unbind from LDAP server: ", $unbind->error."\n"; +} + # List LDAP attributes which have been deprecated sub list_deprecated { my ($obsolete_attrs, $obsolete_classes) = get_deprecated(); @@ -1852,6 +1893,7 @@ die ("! You have to run this script as root\n") if ($<!=0); $commands{"--migrate-systems"} = ["Migrating your systems from FD < 1.1", \&migrate_systems, 1]; $commands{"--migrate-winstations"} = ["Migrating your winstations from FD < 1.1", \&migrate_winstations, 1]; $commands{"--migrate-dhcp"} = ["Migrating DHCP configurations for FD >= 1.0.17",\&migrate_dhcp, 1]; + $commands{"--migrate-supannentite"} = ["Fixing supannTypeEntite from FD < 1.3", \&migrate_supanntypeentite]; $commands{"--delete-gosa-locks"} = ["Delete lock tokens using old gosaLockEntry class", \&delete_gosa_locks]; $commands{"--install-plugins"} = ["Installing FusionDirectory's plugins", \&install_plugins]; $commands{"--encrypt-passwords"} = ["Encrypt passwords in fusiondirectory.conf", \&encrypt_passwords]; @@ -1968,6 +2010,10 @@ This option replace old winstations objectClasses by new objectClasses from FD 1 This option moves DHCP configurations from systems branch to DHCP branch, which is necessary for FusionDirectory 1.0.17 and above. +=item --migrate-supannentite + +This option adds the {SUPANN} prefix that was missing in supannTypeEntite values before FD 1.3. + =item --delete-gosa-locks This option will delete old GOsa style lock tokens from 1.0.15 or older