1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
|
#!/usr/bin/perl
###############################################################################
#
# Programme :\tverification_Email_Annuaire_ADC.pl
#
###############################################################################
#
# Description :\tcomparaison donnees nom, prenom, telephone, mel entre MX1/adc/LDAP
# , exportation ANAIS(Annuaire-organigramme) et aliases de recherche
#
# usage :\t./verification_Email_Annuaire_ADC.pl
#
# $Id: ConstruireExportLDIF_Avec_NUMIND-NUMEN_Infocentre.pl,v 1.1 2006/09/08 05:25:49 eferey Exp eferey $
#
# $Log
#
#
################################################################################
# Packages
use Getopt::Std;
use Net::LDAP qw(LDAP_REFERRAL LDAP_ADMIN_LIMIT_EXCEEDED LDAP_SIZELIMIT_EXCEEDED);
use Net::FLDAP;
use IO::Socket;
use IO::Select;
use Unicode::String qw(latin1 utf8);
use Net::LDAP::Util qw(ldap_error_text ldap_error_name);
use MIME::Base64 qw(encode_base64);
use Email::Valid;
use Digest::SHA1;
#use utf8;
use strict;
sub verif_email {
my $email = $_[0];
if ($email =~ /^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/)
{
return -1;
}
else {
return 0;
}
}
sub format_tel {
my $tel = $_[0];
$tel =~ s/(^ +)|( +$)//g;
$tel =~ s/(^\.+)|(\.+$)//g;
$tel =~ s/O/0/g;
$tel =~ s/\-/ /g;
$tel =~ s/ +/ /g;
$tel =~ s/ /\./g;
$tel =~ s/\. /\./g;
$tel =~ s/\.\.+/\./g;
$tel =~ s/;/\./g;
$tel =~ s/,/\./g;
$tel =~ s/\./-/g;
$tel =~ s/([0-9][0-9])([0-9][0-9])/\1-\2/g;
$tel =~ s/([0-9][0-9])([0-9][0-9])/\1-\2/g;
return $tel;
}
sub SeedHASH {
#use Digest::SHA1;
#use MIME::Base64;
my $tel = $_[0];
my $ctx;
my $hashedPasswd;
$ctx = Digest::SHA1->new;
$ctx->add($tel);
$ctx->add('salt');
$hashedPasswd = '{SSHA}' . encode_base64($ctx->digest . 'salt' ,'');
return $hashedPasswd;
#print 'userPassword: ' . $hashedPasswd . "\n";
}
sub exportligneaccent
{
my($FD, $Ligne) = @_;
$_=$Ligne;
if (/[ÀÁÂÃÄÅaáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèeêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/) {
my @tab=split(/: /,$Ligne);
my $temp = latin1($tab[1])->utf8;
$temp = encode_base64($temp, "");
die "Err04 fichier :\tImpossible d'ecrire dans le fichier de sortie\n" unless print $FD "$tab[0]:: $temp\n";
}
else
{die "Err04 fichier :\tImpossible d'ecrire dans le fichier de sortie\n" unless print $FD "$Ligne\n";}
}
my $chSuffixesMels = " cne-evaluation.fr dr.education.gouv.fr education.gouv.fr espace.gouv.fr recherche.gouv.fr technologie.fr technologie.gouv.fr ";
#-------------------------------------------------------------------------------
# BOUCLE DE CONNEXION AUX SERVEURS LDAP
#-------------------------------------------------------------------------------
my $ligne;
my $ldap;
my $host;
my $mesg;
my $dn;
my $ui;
my $ficout = "./toutesacademiesAdminPersDBF.fusion";
my $ficerr = "./toutesacademiesAdminPersDBF.err";
my $ficlog = "./toutesacademiesAdminPersDBF.log";
my $ficscl="./toutesacademiesAdminPersDBF.pqs";
my $ficDBF="./toutesacademiesAdminPersDBF.DBF.csv";
my $ficBvAnnu="./bvannu.ldif";
my $ficNumenNumind = "PERS_NUMIND_NUMEN.txt";
my $ficCORRServRegion = "./CORR_SERV_REGION.csv";
my $ficCSV="./RecherchePersDBF.CSV";
my $ficzip="./toutesacademiesAdminPersDBF.zip";
my $ficAliases="MessagerieDescartes.txt";
my $ficPasTrouves = "./ListePasTrouvesDBF.csv";
my $ficServices="SERVICE1.csv.UTF8";
my $export_ANAIS="PERSONNE1.csv.UTF8";
my $ficRespAdj = "REL_TITRE_RESPONSABLE.csv";
my $ficNomenType = "type_structure.csv";
my $ficDoublonNaissance = "DOUBLE_AFFECTATION.csv";
my $ficLDIF="./Personnes.ldif";
my $ficServicesLDIF="./Services.ldif";
my $ficRolesLDIF="./Roles.ldif";
open (LDIF,">$ficLDIF") || die ("Err054 fichier :\tImpossible de creer le fichier $ficLDIF");
open (LDIF_SV,">$ficServicesLDIF") || die ("Err054 fichier :\tImpossible de creer le fichier $ficServicesLDIF");
binmode LDIF_SV;
#my $rootdn = "ou=adc,ou=education,o=gouv,c=fr";
my $rootdn = "ou=structures,ou=adc,ou=education,o=gouv,c=fr";
my %lstDescription;
my %lstType;
my %lstPosorg;
my %lstNbRangs;
my %lstNbRateaux;
my %lstSeuil;
my %lstColonne;
my %lstAfficheSigleFin;
my %lstCodeNiveau;
my %lstCodeCouleur;
my %lstParent;
my %lstFonctions;
my %lstrang;
my %lstDN;
my %lstrootDN;
my %lstroleDN;
my %lstroleCN;
my %lstroleDNAutre;
my %lstroleOU;
my %lstroleOuDN;
my %lstroleDESC;
my @TabDN;
$lstrootDN{""} = $rootdn;
$lstrang{""} = 0;
sub convLatin1_BASE64 {
my($Ligne) = @_;
$_=$Ligne;
if (/[ÀÁÂÃÄÅaáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèeêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/) {
my @tab=split(/: /,$Ligne);
my $temp = latin1($tab[1]);
$temp = encode_base64($temp, "");
return "$tab[0]:: $temp";
}
else
{
return "$Ligne";
}
}
sub convUTF8_BASE64 {
my($Ligne) = @_;
$_=$Ligne;
if (/[ÀÁÂÃÄÅaáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèeêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/) {
my @tab=split(/: /,$Ligne);
my $temp = latin1($tab[1])->utf8;
$temp = encode_base64($temp, "");
return "$tab[0]:: $temp";
}
else
{
return "$Ligne";
}
}
sub convBASE64 {
my($Ligne) = @_;
$_=$Ligne;
if (/[ÀÁÂÃÄÅaáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèeêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/) {
my @tab=split(/: /,$Ligne);
my $temp = $tab[1];
# my $temp = latin1($tab[1])->utf8;
$temp = encode_base64($temp, "");
return "$tab[0]:: $temp";
}
else
{
return "$Ligne";
}
}
my %lstsiglesbureaux;
open (LOG,">$ficlog") || die ("Err04 fichier :\tImpossible de creer le fichier $ficlog");
sub DNParent {
my $code = $_[0];
if ($lstsiglesbureaux{$lstParent{$code}}) {
if (not $lstrootDN{$lstParent{$code}}) {DNParent($lstParent{$code});}
if ($lstrootDN{$lstParent{$code}}) {
my $tmprootDN_ = "ou=$lstsiglesbureaux{$code}";
my $tmprootDN = $tmprootDN_;
my $ext = 0;
my $tmpext;
while ($lstDN{"$tmprootDN," . $lstrootDN{$lstParent{$code}}}) {
$tmpext = $ext;
$tmprootDN = $tmprootDN_ . "-$ext";
$ext++;
}
if (defined $tmpext) {$lstsiglesbureaux{$code} .= "-$tmpext";}
$lstrootDN{$code} = "$tmprootDN," . $lstrootDN{$lstParent{$code}};
$lstDN{$lstrootDN{$code}}++;
$lstrang{$code} = $lstrang{$lstParent{$code}} + 1;
$TabDN[$lstrang{$code}]{$code} = $lstrootDN{$code};
} else {
print LOG "Erreur CodeParent : $code, $lstsiglesbureaux{$code}, $lstParent{$code} \n";
}
}
}
my %lstLDIFmels;
my %lstLDIFNomPatros;
my %lstLDIFUserPasswords;
my %lstLDIFCns;
my %lstLDIFGivennames;
my %lstLDIFSns;
my %lstLDIFDns;
my %lstLDIFUids;
my %lstLDIFnoms;
my %lstLDIFprenoms;
my %lstLDIFtels;
my %lstLDIFbureauxCode;
my %lstLDIFbureaux;
my %lstLDIFpieces;
my %lstLDIFbatiments;
my %lstLDIFCodecivilites;
my %lstLDIFMatricules;
my %lstLDIFrangs;
my %lstLDIFmels_modif;
my %lstLDIFTypensis;
my %lstLDIFGradeNumbers;
my %lstLDIFRgNumens;
my %lstLDIFDateNaissances;
my %lstLDIFRgNomPrenomMel;
my %lstLDIFRgMel;
my %lstLDIFRgNomPrenom;
my %lstLDIFRgSOUCIMels;
my %lstLDIFRgSOUCINomsPrenoms;
open(FDDOUBLON, ">$ficDoublonNaissance") or die "immp d'ouv $ficDoublonNaissance en ecriture";
my %lstRespRole;
my %lstRespQual;
my %lstRespResp;
my %lstRespRang;
my %lstRespAdj;
my %lstRespSec;
my %lstRespRang;
open(FD_RA, "<$ficRespAdj") or die "immp d'ouv $ficRespAdj en lecture";
while ($ligne=<FD_RA>) {
chop $ligne;
my @champs=split(/\|/,$ligne);
my $intitule = $champs[0];
if ($lstRespQual{$intitule} && $lstRespQual{$intitule} ne "") {
print STDERR "ERREUR/RESP/Doublon:$intitule;$lstRespRole{$intitule}\n";
}
$lstRespQual{$intitule} = $champs[1];
$lstRespRole{$intitule} = $champs[2];
if (defined $champs[3] && $champs[3] !~ m/^\s*$/) {
$lstRespRang{$intitule} = $champs[3];
}
print $intitule,":",$lstRespQual{$intitule},":",$lstRespRole{$intitule},":",$lstRespRang{$intitule},":","\n";
}
close(FD_RA);
my %lstCodeRegion;
open(FD_RA, "<$ficCORRServRegion") or die "immp d'ouv $ficCORRServRegion en lecture";
while ($ligne=<FD_RA>) {
chop $ligne;
my @champs=split(/\|/,$ligne);
my $code = lc($champs[0]);
$code =~ s/(^\s+)|(\s+$)//g;
my $region = $champs[3];
$region =~ s/(^\s+)|(\s+$)//g;
$lstCodeRegion{$code} = $region;
}
close(FD_RA);
my %lstType;
my %lstTypeNiveau;
my %lstTypeCouleur;
open(FD_RA, "<$ficNomenType") or die "immp d'ouv $ficNomenType en lecture";
while ($ligne=<FD_RA>) {
chop $ligne;
$ligne =~ s/"//g;
my @champs=split(/\|/,$ligne);
my $type = uc($champs[0]);
$type =~ s/(^\s*)|(\s*$)//g;
$champs[1] =~ s/(^\s*)|(\s*$)//g;
$champs[2] =~ s/(^\s*)|(\s*$)//g;
$lstTypeNiveau{$type} = $champs[1];
$lstTypeCouleur{$type} = $champs[2];
}
close(FD_RA);
open(FD_BV, "<$ficBvAnnu") or die "impossible d'ouvrir le fichier $ficBvAnnu en lecture";
my $LDIFRg = -1;
while ($ligne=<FD_BV>) {
chop $ligne;
my @champs=split(/:/,$ligne);
my $valeur = $champs[1];
$valeur =~ s/^ *//;
$valeur =~ s/ *$//;
if ($ligne =~ /^dn:/) {
if ($LDIFRg > 0) {
if ($lstLDIFSns{$LDIFRg} && $lstLDIFGivennames{$LDIFRg} && $lstLDIFmels{$LDIFRg}) {
my $chaine = lc("$lstLDIFSns{$LDIFRg}-$lstLDIFGivennames{$LDIFRg}-$lstLDIFmels{$LDIFRg}");
if ($lstLDIFRgNomPrenomMel{$chaine}) {
print "OOOOOO $lstLDIFRgNomPrenomMel{$chaine} pour $chaine\n";
} else {
$lstLDIFRgNomPrenomMel{$chaine} = $LDIFRg;
}
}
if ($lstLDIFSns{$LDIFRg} && $lstLDIFGivennames{$LDIFRg}) {
my $chaine = lc("$lstLDIFSns{$LDIFRg}-$lstLDIFGivennames{$LDIFRg}");
if ($lstLDIFRgNomPrenom{$chaine}) {
print "OOOO $lstLDIFRgNomPrenom{$chaine} pour $chaine\n";
$lstLDIFRgSOUCINomsPrenoms{$chaine}++;
} else {
$lstLDIFRgNomPrenom{$chaine} = $LDIFRg;
}
}
if ($lstLDIFmels{$LDIFRg}) {
my $chaine = lc("$lstLDIFmels{$LDIFRg}");
if ($lstLDIFRgMel{$chaine}) {
print "OO $lstLDIFRgMel{$chaine} pour $chaine\n";
if (defined $lstLDIFRgSOUCIMels{$chaine}) {
#print "II $lstLDIFRgSOUCIMels{$chaine} [$chaine]\n";
$lstLDIFRgSOUCIMels{$chaine} = $lstLDIFRgSOUCIMels{$chaine} . ", $lstLDIFSns{$LDIFRg} $lstLDIFGivennames{$LDIFRg}";
} else {
my $rang = $lstLDIFRgMel{$chaine};
$lstLDIFRgSOUCIMels{$chaine} = "$lstLDIFSns{$rang} $lstLDIFGivennames{$rang}, $lstLDIFSns{$LDIFRg} $lstLDIFGivennames{$LDIFRg}";
}
} else {
$lstLDIFRgMel{$chaine} = $LDIFRg;
}
}
}
$LDIFRg++;
$lstLDIFDns{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^cn:/) {
if ($lstLDIFCns{$LDIFRg}) {
print STDERR "Erreur UID : Cn $valeur deja utilise ($ligne) -> $lstLDIFCns{$LDIFRg}, $LDIFRg\n";
}
$lstLDIFCns{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^sn:/) {
$lstLDIFSns{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^givenname:/) {
$lstLDIFGivennames{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^userpassword:/) {
$lstLDIFUserPasswords{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^employeenumber:/) {
$lstLDIFMatricules{$LDIFRg} = $valeur;
$lstLDIFRgNumens{uc($valeur)} = $LDIFRg;
} elsif ($ligne =~ /^datenaissance:/) {
$lstLDIFDateNaissances{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^codecivilite:/) {
$lstLDIFCodecivilites{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^grade:/) {
$lstLDIFGradeNumbers{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^typensi:/) {
$lstLDIFTypensis{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^uid:/) {
if ($lstLDIFUids{$LDIFRg}) {
print STDERR "Erreur UID : uid $valeur deja utilise ($ligne)\n";
}
$lstLDIFUids{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^nompatro:/) {
$lstLDIFNomPatros{$LDIFRg} = $valeur;
} elsif ($ligne =~ /^mailmondossier:/) {
$lstLDIFmels{$LDIFRg} = $valeur;
} elsif (!defined $lstLDIFmels{$LDIFRg} && $ligne =~ /^mail:/) {
$lstLDIFmels{$LDIFRg} = $valeur;
}
}
close(FD_BV);
if ($LDIFRg > 0) {
if ($lstLDIFSns{$LDIFRg} && $lstLDIFGivennames{$LDIFRg} && $lstLDIFmels{$LDIFRg}) {
my $chaine = lc("$lstLDIFSns{$LDIFRg}-$lstLDIFGivennames{$LDIFRg}-$lstLDIFmels{$LDIFRg}");
if ($lstLDIFRgNomPrenomMel{$chaine}) {
print "OOOOOO $lstLDIFRgNomPrenomMel{$chaine} pour $chaine\n";
} else {
$lstLDIFRgNomPrenomMel{$chaine} = $LDIFRg;
}
}
if ($lstLDIFSns{$LDIFRg} && $lstLDIFGivennames{$LDIFRg}) {
my $chaine = lc("$lstLDIFSns{$LDIFRg}-$lstLDIFGivennames{$LDIFRg}");
if ($lstLDIFRgNomPrenom{$chaine}) {
print "OOOO $lstLDIFRgNomPrenom{$chaine} pour $chaine\n";
$lstLDIFRgSOUCINomsPrenoms{$chaine}++;
} else {
$lstLDIFRgNomPrenom{$chaine} = $LDIFRg;
}
}
if ($lstLDIFmels{$LDIFRg}) {
my $chaine = lc("$lstLDIFmels{$LDIFRg}");
if ($lstLDIFRgMel{$chaine}) {
print "OO $lstLDIFRgMel{$chaine} pour $chaine\n";
if ($lstLDIFRgSOUCIMels{$chaine}) {
$lstLDIFRgSOUCIMels{$chaine} = $lstLDIFRgSOUCIMels{$chaine} . ", $lstLDIFSns{$LDIFRg} $lstLDIFGivennames{$LDIFRg}";
} else {
my $rang = $lstLDIFRgMel{$chaine};
$lstLDIFRgSOUCIMels{$chaine} = "$lstLDIFSns{$rang} $lstLDIFGivennames{$rang}, $lstLDIFSns{$LDIFRg} $lstLDIFGivennames{$LDIFRg}";
}
} else {
$lstLDIFRgMel{$chaine} = $LDIFRg;
}
}
}
foreach my $clef (keys %lstLDIFRgSOUCIMels) {
print LOG "Doublons-mels $clef -> $lstLDIFRgSOUCIMels{$clef}\n";
}
foreach my $clef (keys %lstLDIFRgSOUCINomsPrenoms) {
if ($lstLDIFRgSOUCINomsPrenoms{$clef} >= 1 ) {print LOG "Doublons-noms-prenoms $clef -> $lstLDIFRgSOUCINomsPrenoms{$clef}\n";}
}
open(FD_SERV, "<$ficServices") or die "impossible d'ouvrir le fichier $ficServices en lecture";
my $rg = 0;
binmode FD_SERV;
while ($ligne=<FD_SERV>) {
if ($. > 1) {
chop $ligne;
$ligne =~ s/\"//g;
my $academie = $ligne;
my @champs=split(/\|/,$academie);
$rg++;
my $code = lc($champs[0]);
my $code_parent = lc($champs[1]);
my $posorg = $champs[8];
my $type = uc($champs[9]);
my $nbrang = $champs[10];
my $nbrat = $champs[11];
my $afflib = $champs[12];
my $seuil = $champs[13];
my $colonne = $champs[14];
my $description = $champs[5];
my $sigle = lc($champs[4]);
$code =~ s/(^ +)|( +$)//g;
$code_parent =~ s/(^ +)|( +$)//g;
$description =~ s/(^ +)|( +$)//g;
$sigle =~ s/(^ +)|( +$)//g;
if (!defined $sigle || $sigle =~ /^\s*$/) {
print STDERR "$ligne\n";
}
$lstsiglesbureaux{$code} = $sigle;
#print "SIGLEPARENT : $code->$sigle \n";
$lstDescription{$code} = $description;
$lstType{$code} = $type;
if ($lstTypeNiveau{$type} && $lstTypeNiveau{$type} !~ m/^\s*$/) {
$lstCodeNiveau{$code} = $lstTypeNiveau{$type};
}
if ($lstTypeCouleur{$type} && $lstTypeCouleur{$type} !~ m/^\s*$/) {
$lstCodeCouleur{$code} = $lstTypeCouleur{$type};
}
$lstPosorg{$code} = $posorg;
$lstNbRangs{$code} = $nbrang;
$lstNbRateaux{$code} = $nbrat;
$lstAfficheSigleFin{$code} = $afflib;
$lstSeuil{$code} = $seuil;
$lstColonne{$code} = $colonne;
$lstParent{$code} = $code_parent;
if ($lstrootDN{$lstParent{$code}}) {
my $tmprootDN_ = "ou=$lstsiglesbureaux{$code}";
my $tmprootDN = $tmprootDN_;
my $ext = 0;
my $tmpext;
while ($lstDN{"$tmprootDN," . $lstrootDN{$lstParent{$code}}}) {
$tmpext = $ext;
$tmprootDN = $tmprootDN_ . "-$ext";
$ext++;
}
if (defined $tmpext) {$lstsiglesbureaux{$code} .= "-$tmpext";}
$lstrootDN{$code} = "$tmprootDN," . $lstrootDN{$lstParent{$code}};
$lstDN{$lstrootDN{$code}}++;
$lstrang{$code} = $lstrang{$lstParent{$code}} + 1;
$TabDN[$lstrang{$code}]{$code} = $lstrootDN{$code};
}
} else {
if ($ligne !~ /^CODESTR/) {
print STDERR "Attention : il manque l'en-tete dans le fichier Services/Structures\n";
}
}
}
foreach my $code (keys %lstsiglesbureaux) {
if (not $lstrootDN{$code}) { DNParent($code);}
}
close FD_SERV;
my %lstmels;
my %lstnoms;
my %lstprenoms;
my %lsttels;
my %lstbureauxCode;
my %lstbureaux;
my %lstpieces;
my %lstdescriptions;
my %lstNomPatros;
my %lstnaissances;
my %lstnomprenomnaissance;
my %lstbatiments;
my %lstgrades;
my %lstsites;
my %lstcivilites;
my %lstmatricules;
my %lstrangs;
my %lstfaxs;
my %lstmels_modif;
my %nbhomonymes;
my %nbhomonymesmels;
my $rang = 0;
my $academie;
##################
open(FD_NUM, "<$ficNumenNumind") or die "impossible d'ouvrir le fichier $ficNumenNumind en lecture";
my %lstNumindNumen;
while ($ligne=<FD_NUM>) {
$ligne =~ s/\"//g;
chop $ligne;
my $academie = $ligne;
my @champs=split(/\|/,$academie);
if ($. > 1) {
my $Numind = $champs[99];
$Numind =~ s/(^\s+)|(\s+$)//g;
my $Numen = $champs[6];
$Numen =~ s/(^\s+)|(\s+$)//g;
if ($Numen =~ m/^\s*$/ || $Numind =~ m/^\s*$/) {
print FDLOG "ERR/NumindNumen : non defini [$Numind,$Numen]\n";
}
if ($lstNumindNumen{$Numind}) {
print FDLOG "ERR/NumindNumen : $Numind a deja un numen $Numen\n";
}
$lstNumindNumen{$Numind} = uc($Numen);
}
}
close(FD_NUM);
##################
open (PTLOG,">$ficPasTrouves") || die ("Err054 fichier :\tImpossible de creer le fichier $ficPasTrouves");
open (CSV,">$ficCSV") || die ("Err054 fichier :\tImpossible de creer le fichier $ficCSV");
#binmode CSV;
open (DBF,">$ficDBF") || die ("Err054 fichier :\tImpossible de creer le fichier $ficDBF");
open(FD_ACAD, "<$export_ANAIS") or die "impossible d'ouvrir le fichier academies.txt en lecture";
while ($ligne=<FD_ACAD>) {
$ligne =~ s/\"//g;
chop $ligne;
#my $academie = lc($ligne);
my $academie = $ligne;
my @champs=split(/\|/,$academie);
if ($. > 1) {
$rang++;
$lstmels{$rang} = $champs[106];
if (($champs[106] && $champs[106] ne "") && !Email::Valid->rfc822($champs[106])) {
print LOG "Error ANAIS :\tmail invalide [".$champs[106]."] pour $champs[101],$champs[102] dans EXPORT_ANAIS\n";
$lstmels_modif{$rang} = 1;
}
if ($champs[101] =~ /^[[:space:]]*$/) {
if (!($champs[1] =~ /^[[:space:]]*$/ || $champs[99] =~ /^[[:space:]]*$/)) {
print LOG "Error ANAIS :\tnom invalide [".$champs[101]."] pour $champs[101],$champs[102] a $rang ligne, dans EXPORT_ANAIS\n";
print STDERR "Error ANAIS :\tnom invalide [".$champs[101]."] pour $champs[101],$champs[102] a $rang ligne, dans EXPORT_ANAIS\n";
}
}
else {
$lstnoms{$rang} = $champs[101];
$lstgrades{$rang} = $champs[103];
$lstprenoms{$rang} = $champs[102];
$lstmatricules{$rang} = lc($champs[99]);
$lstcivilites{$rang} = lc($champs[99]);
$lstpieces{$rang} = $champs[13];
$lstdescriptions{$rang} = $champs[4];
$lstNomPatros{$rang} = $champs[2];
$lstnaissances{$rang} = $champs[5];
my $nomprenomnaissance = "$champs[101] $champs[102] $champs[5]";
my $tmpExiste = $lstnomprenomnaissance{$nomprenomnaissance};
if ($nomprenomnaissance && $nomprenomnaissance !~ m/^\s*$/ && $tmpExiste && $tmpExiste !~ m/^\s*$/) {
print STDERR "ERREUR/Doublon/Naissance: $tmpExiste;$champs[99];$nomprenomnaissance\n";
print FDDOUBLON "$tmpExiste;$champs[99];$lstnoms{$rang};$lstprenoms{$rang};$lstnaissances{$rang}\n";
} else {
$lstnomprenomnaissance{$nomprenomnaissance} = $lstmatricules{$rang};
}
$lstbatiments{$rang} = $champs[14];
$lstbatiments{$rang} =~ s/(^\s*)|(\s*$)//g;
$lstsites{$rang} = $champs[24];
$lstbureauxCode{$rang} = $champs[1];
my $Fonction = $champs[3];
$lstFonctions{$rang} = $Fonction;
$lstbureaux{$rang} = $lstsiglesbureaux{lc($champs[1])};
$lsttels{$rang} = $champs[7];
$lstcivilites{$rang} = $champs[8];
$lstfaxs{$rang} = $champs[11];
$nbhomonymes{"$champs[101]$champs[102]"}++;
$nbhomonymesmels{"$champs[106]"}++;
###### RAJOUT 10/03/2004
print CSV $lstmels{$rang} . "|" . $lsttels{$rang} . "|||||" . $lstnoms{$rang} . "|" .$lstprenoms{$rang} . "|" . $lstbureaux{$rang} . "|" . $lstDescription{$lstbureauxCode{$rang}} . "|" . $Fonction . "|" . $lstpieces{$rang} . "|" . $lstbatiments{$rang} . "|" . $lstsites{$rang} . "||" . "\n";
##########
if ($nbhomonymes{"$champs[101]$champs[102]"}>1) {
if ($nbhomonymes{"$champs[101]$champs[102]"} ne $nbhomonymesmels{"$champs[106]"}) { print LOG $nbhomonymes{"$champs[101]$champs[102]"} . " * HOMONYMES POTENTIELS :\t" . "$champs[101] $champs[102]\n";}
else {print LOG $nbhomonymes{"$champs[101]$champs[102]"} . " * HOMONYMES A PRIORI FAUX :\t" . "$champs[101] $champs[102]\n";}
}
# print $rang . $lstmels[$rang] . $lstnoms[$rang] . $lstprenoms[$rang] . $lsttels[$rang] . "\n";
}
}
else {print DBF "$champs[99]|$champs[101]|$champs[102]|$champs[7]|$champs[106]\n";}
}
print "Nom_ANAIS\tPrenom_ANAIS\tTel_ANAIS\tMel_ANAIS\tComp_Mel\tComp_Tel\tComp_Prenom\tNom_Messagerie\tPrenom_Messg\tMel_Messg\tTel_Messg\tEquiv_Messg\tMel_Recherche\tMel_Aliases\tMiseAJour\tProbabilite\n";
################
# ATTENTION aux valeurs multiples!!!
################
print LOG "Ca demarre\n";
foreach my $clef (keys %lstnoms) {
my %listeLDAPtrouvesinv;
my $LDAPouALIASEStrouve;
my $MaJ = 0;
my $MaJtemp = 0;
my $ValidEmail = 0;
my $nom = $lstnoms{$clef};
my $telMODIF = "";
my $mailMODIF = "";
my $prenom = $lstprenoms{$clef};
my $bureauCodeMAJ = $lstbureauxCode{$clef};
my $bureauCode = lc($bureauCodeMAJ);
my $bureau = $lstbureaux{$clef};
my $piece = $lstpieces{$clef};
my $description = $lstdescriptions{$clef};
my $Title = $lstFonctions{$clef};
my $tempDN;
my $site = $lstsites{$clef};
my $nompatro = $lstNomPatros{$clef};
my $naissance = $lstnaissances{$clef};
my $batiment = $lstbatiments{$clef};
my $civilite = $lstcivilites{$clef};
my $matricule = $lstmatricules{$clef};
my $mel = $lstmels{$clef};
my $filtre="$nom";
my $grade = $lstgrades{$clef};
my $fax = format_tel($lstfaxs{$clef});
my $telephone = $lsttels{$clef};
my $teleph = format_tel($telephone);
my $telephone_modif;
my $mel_modif = $lstmels_modif{$clef};
if (defined $telephone && $telephone ne "" && $telephone !~ /^[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]$/) {
print LOG "Error ANAIS :\ttel invalide [".$telephone."]pour $prenom,$nom,$mel\n";
print LOG "Error ANAIS :\ttel invalide [".$telephone."]pour $prenom,$nom,$mel\n";
if ($teleph eq $telephone) {
$telephone_modif = 1;
} elsif ($teleph =~ /^[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]$/) {
$MaJtemp += 1;
} else {
$telephone_modif = 2;
}
}
$telephone = $teleph;
######## FIN ALIAS |
Partager