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 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
|
Sub Creation_Groupes_Niveau_1
on error resume next
' > Creation des groupe de dossier de Niveau 1 <
Set oOUGroup = GetObject(v_OU_Dossiers_N_1)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_1_Ecriture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_1_Ecriture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_1)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_1_Lecture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_1_Lecture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_1)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_1_Acces)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_1_Acces
oGroup.SetInfo
End Sub
Sub Creation_Groupes_Niveau_2
on error resume next
' > Creation des groupe de dossier de Niveau 1 <
Set oOUGroup = GetObject(v_OU_Dossiers_N_2)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_2_Ecriture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_2_Ecriture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_2)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_2_Lecture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_2_Lecture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_2)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_2_Acces)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_2_Acces
oGroup.SetInfo
End Sub
Sub Creation_Groupes_Niveau_3
on error resume next
' > Creation des groupe de dossier de Niveau 1 <
Set oOUGroup = GetObject(v_OU_Dossiers_N_3)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_3_Ecriture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_3_Ecriture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_3)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_3_Lecture)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_3_Lecture
oGroup.SetInfo
Set oOUGroup = GetObject(v_OU_Dossiers_N_3)
Set oGroup = oOUGroup.Create("Group", "cn=" & v_Groupe_Niveau_3_Acces)
oGroup.Put "sAMAccountName", v_Groupe_Niveau_3_Acces
oGroup.SetInfo
End Sub
Sub Niveau_2_All_Membre_De_Niveau_1_Acces
on error resume next
Set oOUGroup = GetObject(v_OU_Dossiers_N_1)
Set oOUGroup2 = GetObject(v_OU_Dossiers_N_2)
' > Mettre le Groupe Ordinateurs-Entites-Portables membre du Groupe Ordinateurs-Entite-All <
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_1_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Lecture)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_1_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Ecriture)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_1_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Acces)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
End Sub
Sub Niveau_3_All_Membre_De_Niveau_2_Acces
on error resume next
Set oOUGroup = GetObject(v_OU_Dossiers_N_2)
Set oOUGroup2 = GetObject(v_OU_Dossiers_N_3)
' > Mettre le Groupe Ordinateurs-Entites-Portables membre du Groupe Ordinateurs-Entite-All <
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_3_Lecture)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_3_Ecriture)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
Set oGroup = oOUGroup.GetObject("Group", "cn=" & v_Groupe_Niveau_2_Acces)
Set oGroupOf = oOUGroup2.GetObject("Group", "cn=" & v_Groupe_Niveau_3_Acces)
oGroup.SetInfo
oGroup.Add oGroupOf.ADSPath
End Sub
Sub Creation_Dossiers_N1
Set objNiveau1Path = CreateObject("Scripting.FileSystemObject")
' > Creation du Dossier Niveau 1 <
If objNiveau1Path.FolderExists(Niveau1Path) Then
v_DossierExiste = True
Else
v_DossierExiste = False
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr3 Then
Exit Sub
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr1 Then
Call Solicitation_Ajout_Droits_Dossiers_Existants_N1()
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr2 Then
Call Solicitation_Remplacer_Droits_Dossiers_Existants_N1()
End If
If v_DossierExiste = False Then
Set objNiveau1Path = objFSO.CreateFolder(Niveau1Path)
' > Inscription Log <
If Err.Number <> 0 Then
Ftxt_Log.Writeline Date & ";" & "ERREUR" & ";" & "CREATION DOSSIER" & ";" & "Log13" & ";" & "Le Dossier " & Niveau1Path & " n'à pas pu être créer " & ";" & Err.Description
Else
Ftxt_Log.Writeline Date & ";" & "OK" & ";" & "CREATION DOSSIER" & ";" & "Log13" & ";" & "Le Dossier " & Niveau1Path & " à été crée"
End If
End If
If v_DossierExiste = False AND v_flag_Groupes_AD = 6 Then
Call Application_Droits_Dossiers_N1
End If
Err.Clear
End Sub
Sub Creation_Dossiers_N2
Set objNiveau2Path = CreateObject("Scripting.FileSystemObject")
' > Creation du Dossier Niveau 2 <
If objNiveau2Path.FolderExists(Niveau2Path) Then
v_DossierExiste = True
Else
v_DossierExiste = False
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr3 Then
Exit Sub
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr1 Then
Call Solicitation_Ajout_Droits_Dossiers_Existants_N2()
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr2 Then
Call Solicitation_Remplacer_Droits_Dossiers_Existants_N2()
End If
If v_DossierExiste = False Then
Set objNiveau2Path = objFSO.CreateFolder(Niveau2Path)
' > Inscription Log <
If Err.Number <> 0 Then
Ftxt_Log.Writeline Date & ";" & "ERREUR" & ";" & "CREATION DOSSIER" & ";" & "Log23" & ";" & "Le Dossier " & Niveau2Path & " n'à pas pu être créer " & ";" & Err.Description
Else
Ftxt_Log.Writeline Date & ";" & "OK" & ";" & "CREATION DOSSIER" & ";" & "Log23" & ";" & "Le Dossier " & Niveau2Path & " à été crée"
End If
End If
If v_DossierExiste = False AND v_flag_Groupes_AD = 6 Then
Call Application_Droits_Dossiers_N2
End If
Err.Clear
End Sub
Sub Creation_Dossiers_N3
Set objNiveau3Path = CreateObject("Scripting.FileSystemObject")
' > Creation du Dossier Niveau 3 <
If objNiveau3Path.FolderExists(Niveau3Path) Then
v_DossierExiste = True
Else
v_DossierExiste = False
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr3 Then
Exit Sub
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr1 Then
Call Solicitation_Ajout_Droits_Dossiers_Existants_N3()
End If
If v_DossierExiste = True AND v_flag_Droits_Dossiers_Existants = ChDr2 Then
Call Solicitation_Remplacer_Droits_Dossiers_Existants_N3()
End If
If v_DossierExiste = False Then
Set objNiveau3Path = objFSO.CreateFolder(Niveau3Path)
' > Inscription Log <
If Err.Number <> 0 Then
Ftxt_Log.Writeline Date & ";" & "ERREUR" & ";" & "CREATION DOSSIER" & ";" & "Log33" & ";" & "Le Dossier " & Niveau3Path & " n'à pas pu être créer " & ";" & Err.Description
Else
Ftxt_Log.Writeline Date & ";" & "OK" & ";" & "CREATION DOSSIER" & ";" & "Log33" & ";" & "Le Dossier " & Niveau3Path & " à été crée"
End If
End If
If v_DossierExiste = False AND v_flag_Groupes_AD = 6 Then
Call Application_Droits_Dossiers_N3
End If
Err.Clear
End Sub
Sub Application_Droits_Dossiers_N1()
Act.Run("icacls " & Chr(34) & Niveau1Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_1_Ecriture & Chr(34) & ":(OI)(CI)(RC,RD,WD,AD,REA,WEA,X,DC,RA,WA) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau1Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_1_Lecture & Chr(34) & ":(OI)(CI)(NP)(RX) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau1Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_1_Acces & Chr(34) & ":(NP)(RX) /T /C"),7,True
End Sub
Sub Application_Droits_Dossiers_N2()
Act.Run("icacls " & Chr(34) & Niveau2Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_2_Ecriture & Chr(34) & ":(OI)(CI)(RC,RD,WD,AD,REA,WEA,X,DC,RA,WA) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau2Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_2_Lecture & Chr(34) & ":(OI)(CI)(NP)(RX) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau2Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_2_Acces & Chr(34) & ":(NP)(RX) /T /C"),7,True
End Sub
Sub Application_Droits_Dossiers_N3()
Act.Run("icacls " & Chr(34) & Niveau3Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_3_Ecriture & Chr(34) & ":(OI)(CI)(RC,RD,WD,AD,REA,WEA,X,DC,RA,WA) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau3Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_3_Lecture & Chr(34) & ":(OI)(CI)(NP)(RX) /T /C"),7,True
Act.Run("icacls " & Chr(34) & Niveau3Path & Chr(34) & " /grant " & Chr(34) & v_Groupe_Niveau_3_Acces & Chr(34) & ":(NP)(RX) /T /C"),7,True
End Sub
Sub Solicitation_Ajout_Droits_Dossiers_Existants_N1()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Ajout_Existant = 6 Then
v_flag_Confirmation_Droits_N1_Ajout = msgbox ("Ceci va Ajouter les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Ajout des Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau1Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N1_Ajout = 6 OR v_flag_Solicitation_Ajout_Existant = 7 Then
Call Application_Droits_Dossiers_N1
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau1Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N1_Ajout = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N1_Ajout = 2 Then
WScript.Quit
End If
End Sub
Sub Solicitation_Ajout_Droits_Dossiers_Existants_N2()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Ajout_Existant = 6 Then
v_flag_Confirmation_Droits_N2_Ajout = msgbox ("Ceci va Ajouter les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Ajout des Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau2Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N2_Ajout = 6 OR v_flag_Solicitation_Ajout_Existant = 7 Then
Call Application_Droits_Dossiers_N2
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau2Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N2_Ajout = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N2_Ajout = 2 Then
WScript.Quit
End If
End Sub
Sub Solicitation_Ajout_Droits_Dossiers_Existants_N3()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Ajout_Existant = 6 Then
v_flag_Confirmation_Droits_N3_Ajout = msgbox ("Ceci va Ajouter les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & "\" & v_Niveau_3 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Ajout des Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau3Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N3_Ajout = 6 OR v_flag_Solicitation_Ajout_Existant = 7 Then
Call Application_Droits_Dossiers_N3
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau3Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N3_Ajout = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N3_Ajout = 2 Then
WScript.Quit
End If
End Sub
Sub Solicitation_Remplacer_Droits_Dossiers_Existants_N1()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Remplacer_Existant = 6 Then
v_flag_Confirmation_Droits_N1_Remplacer = msgbox ("Ceci va Remplacer les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Remplacementdes Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau1Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N1_Remplacer = 6 OR v_flag_Solicitation_Remplacer_Existant = 7 Then
Act.Run("icacls " & Chr(34) & Niveau1Path & Chr(34) & " /reset /T /C"),7,True
Call Application_Droits_Dossiers_N1
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau1Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N1_Remplacer = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N1_Remplacer = 2 Then
WScript.Quit
End If
End Sub
Sub Solicitation_Remplacer_Droits_Dossiers_Existants_N2()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Remplacer_Existant = 6 Then
v_flag_Confirmation_Droits_N2_Remplacer = msgbox ("Ceci va Remplacer les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Remplacement des Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau2Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N2_Remplacer = 6 OR v_flag_Solicitation_Remplacer_Existant = 7 Then
Act.Run("icacls " & Chr(34) & Niveau2Path & Chr(34) & " /reset /T /C"),7,True
Call Application_Droits_Dossiers_N2
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau2Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N2_Remplacer = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N2_Remplacer = 2 Then
WScript.Quit
End If
End Sub
Sub Solicitation_Remplacer_Droits_Dossiers_Existants_N3()
'Si la Solicitation est OUI alors on appelle la msgbox de confirmation
If v_flag_Solicitation_Remplacer_Existant = 6 Then
v_flag_Confirmation_Droits_N3_Remplacer = msgbox ("Ceci va Remplacer les Droits sur le dossier existant " & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & "\" & v_Niveau_3 & VBcrlf & VBcrlf & "Voulez vous procéder ?", 51 + vbMsgBoxHelpButton, "Remplacement des Droits", FichierAide, 101)
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau3Path
End If
'Si la confirmation est OUI ou que pas de Solicitation, appelle l'application dse Droits
If v_flag_Confirmation_Droits_N3_Remplacer = 6 OR v_flag_Solicitation_Remplacer_Existant = 7 Then
Act.Run("icacls " & Chr(34) & Niveau3Path & Chr(34) & " /reset /T /C"),7,True
Call Application_Droits_Dossiers_N3
' > Inscription Log <
Ftxt_Log.Writeline Date & ";" & "INFO" & ";" & "DROITS" & ";" & "Les Droits ont été ajoutés sur " & Niveau3Path
End IF
'Si la confirmation est NON, on sort
If v_flag_Confirmation_Droits_N3_Remplacer = 7 Then
Exit Sub
End If
'Si la confirmation est ANNULE, on quit le script
If v_flag_Confirmation_Droits_N3_Remplacer = 2 Then
WScript.Quit
End If
End Sub
'##### Debut du script #####
Set objFSO = CreateObject("Scripting.FileSystemObject")
' > Concatenation de la Date pour le fichier de log <
DateHeure = Now
Annee = Mid(Now, 7, 4)
Mois = Mid(Now, 4, 2)
Jour = Mid(Now, 1, 2)
Heures = Mid(Now, 12, 2)
Minutes = Mid(Now, 15, 2)
Secondes = Mid(Now, 18, 2)
AAAAMMJJ_HHNN = Annee & Mois & Jour & "_" & Heures & Minutes
' > Utilisation des fichiers d'import, d'aide et de log
Dim fichier_log
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
Set Ftxt_Users = objFSO.OpenTextFile(objArgs(I))
fichier_log = objArgs(I) & "_log.csv"
Set Ftxt_Log = objFSO.OpenTextFile(fichier_log, 8, True)
Next
' Recuperation du chemin relatif où s'execute le script pour appeler le fichier d'aide
ScriptPath = Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName) - (Len(WScript.ScriptName) + 1)))
FichierAide = ScriptPath & "\" & "Help.hlp"
' > Recuperation des infos du Domaine <
Set oRoot = GetObject("LDAP://rootDSE")
Set oDomain = GetObject("LDAP://" & oRoot.Get("defaultNamingContext"))
' > Recuperation et Concatenation du nom du Domaine <
NomADSpath = oRoot.Get("defaultNamingContext")
arrDomLevels = Split(NomADSpath, "DC=")
NomDomaineTemp = "" & Join(arrDomLevels, "")
arrDomLevels2 = Split(NomDomaineTemp, ",")
NomDomaine = "" & Join(arrDomLevels2, ".")
' > Recuperation Nom de la Machine Locale <
Set objComputer = CreateObject("Shell.LocalMachine")
v_Nom_Machine_Local = objComputer.MachineName
'### > Interaction Choix Utilisateur < ###
Dim v_Erreur_Saisie
Const ChDr1 = "AJOUTER"
Const ChDr2 = "REMPLACER"
Const ChDr3 = "PASSER"
' Explication
v_flag = msgbox ("Ce Script va créer vos Dossiers et y appliquer les Droits relatifs via des goupes qui vont être crées dans l'AD, le tout basé sur votre Fichier CSV." & VBcrlf & VBcrlf & "Si votre CSV contient des Dossiers existants, vous aurez également la possibilité de Remplacer les Droits sur ces derniers." & VBcrlf & VBcrlf & "Note : A tout moment vous pouvez consulter l'aide en cliquant sur le bouton Aide" & VBcrlf & VBcrlf & "Voulez vous continuer ?", 68 + vbMsgBoxHelpButton, "Execution du Script", FichierAide, 101)
If v_flag = 7 Then
WScript.Quit
End If
' Choix de l'emplacement de la machine
v_Emplacement = msgbox ("Voulez-vous executer ce script sur le Poste Local ?" & VBcrlf & VBcrlf & "Cliquez sur Non si vous voulez créer votre architecture sur un poste du réseau", 3 + vbMsgBoxHelpButton, "Choix Emplacment", FichierAide, 101)
If v_Emplacement = 2 Then
WScript.Quit
End If
' Si Emplacement de la machine = Reseau
If v_Emplacement = 7 Then
v_Nom_Machine = inputbox ("Quel est le Nom du poste distant ?" & VBcrlf & VBcrlf & "Ex : SRV-TEST-001" & VBcrlf & VBcrlf & "Attention : Ne mettez pas d'Adresse IP", "Choix du Poste Distant",,,, FichierAide, 101)
v_Lecteur_Affiche = "D$"
If v_Nom_Machine = "" then
v_flag_annule = msgbox ("Vous n'avez pas rensigné le champ. Action Annulée", 16)
WScript.Quit
End if
End If
' Si Emplacement de la machine = Locale
If v_Emplacement = 6 Then
v_Nom_Machine = v_Nom_Machine_Local
v_Lecteur_Affiche = "D:"
If v_Nom_Machine = "" then
v_flag_annule = msgbox ("Vous n'avez pas rensigné le champ. Action Annulée", 16)
WScript.Quit
End If
End If
' Choix du Chemin Principal
v_Lecteur_Path = inputbox ("Quel est le chemin relatif où sera stocké votre dossier principal ?" & VBcrlf & VBcrlf & "Exemple :" & VBcrlf & "D: pour une machine Local" & VBcrlf & "D$ pour une machine Distante" & VBcrlf, "Chemin du Dossier Principal", v_Lecteur_Affiche,,, FichierAide, 101)
If v_Lecteur_Path = "" then
v_flag_annule = msgbox ("Vous n'avez pas renseigné le Champ. Action Annulée", 16)
WScript.Quit
End If
' Creations Groupes Active Directory
v_flag_Groupes_AD = msgbox ("Souhaitez vous la création des Groupes de Sécurité de Dossiers dans Active Directory vous permettant d'appliquer les Droits sur les Dossiers ?" & VBcrlf & VBcrlf & "Si vous répondez Oui, les Groupes seront crées dans les OU standardisée par "Mon Choix" et vous permettront d'appliquer ou non les Droits sur les dossiers par la suite." & VBcrlf & VBcrlf & "Si vous répondez Non, aucun groupe ne sera crée dans Active Directory et le choix pour l'application, l'ajout ou la réinitialisation des Droits n'auront pas lieu (Déconseillé).", 67 + vbMsgBoxHelpButton, "Création Groupes", FichierAide, 101)
' Dossiers Existants ?
'v_flag_Dossiers_Existants = msgbox ("Il y a t-il des Dossiers déjà existant dans l'architecture par rapport à votre fichier d'import ?" & VBcrlf & VBcrlf & "Répondez Oui si tel est le cas." & VBcrlf & VBcrlf & "Répondez Non s'il s'agit d'une création d'une nouvelle structure.", 67 + vbMsgBoxHelpButton, "Dossiers Exsitant", FichierAide, 101)
' Si Oui creation Groupe AD, Demande Ajouts Droits
If v_flag_Groupes_AD = 6 Then
If v_flag_Droits_Dossiers_Existants = 2 Then
wscript.quit
End If
Do While v_flag_Droits_Dossiers_Existants = Empty OR (v_flag_Droits_Dossiers_Existants <> ChDr2 AND v_flag_Droits_Dossiers_Existants <> ChDr1 AND v_flag_Droits_Dossiers_Existants <> ChDr3)
v_flag_Droits_Dossiers_Existants = inputbox ("Si des Dossiers existent déjà, comment le script doit-il agir ?" & VBcrlf & VBcrlf & VBcrlf & "Si vous souhaitez conserver les Droits existants sur les dossiers en y ajoutant les Droits générés par le script alors :" & VBcrlf & VBcrlf & "Entrez " & ChDr1 & " et continuez." & VBcrlf & VBcrlf & VBcrlf & "Si vous ne souhaitez pas conserver les droits existants ou que vous voulez rétablir les Droits générés par le script par défaut en cas de modification alors :" & VBcrlf & VBcrlf & "Entrez " & ChDr2 & " et continuez." & VBcrlf & VBcrlf & VBcrlf & "Si vous ne souhaitez appliquer aucun Droits alors :" & VBcrlf & VBcrlf & "Entrez " & ChDr3 & " et continuez." & VBcrlf & VBcrlf & VBcrlf & "NOTE : Pour les 2 premiers choix, vous aurez par la suite la possibilité d'appliquer votre choix sur un dossier spécifique ou sur l'enssemble des dossiers." & VBcrlf, "Droits pour les Dossiers Existants",,,, FichierAide, 101)
IF v_flag_Droits_Dossiers_Existants = ChDr1 OR v_flag_Droits_Dossiers_Existants = ChDr2 OR v_flag_Droits_Dossiers_Existants = ChDr3 Then
Exit Do
Else
v_Erreur_Saisie = msgbox ("Vous n'avez pas entrer une valeur correcte. Voulez-vous recommencer ?", 52, "Erreur de Saisie")
End If
If v_Erreur_Saisie = 7 Then
wscript.quit
End If
Loop
End If
' Si Ajout de Droit sur les Dossiers Existants, Solicitation ?
If v_flag_Droits_Dossiers_Existants = ChDr1 Then
v_flag_Solicitation_Ajout_Existant = msgbox ("Vous avez choisi d'Ajouter des droits sur des dossiers existants qui serai susceptibles d'être detectés. Voulez vous être solicité pour chaque dossiers détectés ?" & VBcrlf & VBcrlf & "Attention : Si vous répondez Non, les droits seront ajoutés sur l'enssemble des dossiers automatiquement", 51 + vbMsgBoxHelpButton, "Solicitation sur les Dossiers", FichierAide, 101)
End if
If v_flag_Solicitation_Ajout_Existant = 2 Then
WScript.Quit
End if
' Si Remplacement de Droit sur les Dossiers Existants, Solicitation ?
If v_flag_Droits_Dossiers_Existants = ChDr2 Then
v_flag_Solicitation_Remplacer_Existant = msgbox ("Vous avez choisi de Remplacer des droits sur des dossiers existants. Voulez vous être solicité pour chaque dossiers ?" & VBcrlf & VBcrlf & "Attention : Si vous répondez Non, les droits seront réinitialisés sur l'enssemble des dossiers automatiquement", 51 + vbMsgBoxHelpButton, "Solicitation sur les Dossiers", FichierAide, 101)
End If
If v_flag_Solicitation_Remplacer_Existant = 2 Then
WScript.Quit
End if
' > Utilisation du Fichier CSV <
' Permet de passer la premiere ligne du csv qui contient les champs
Ligne = Ftxt_Users.Readline
v_Dernier_N1 = ""
v_Dernier_N2 = ""
Do While (Not Ftxt_Users.AtEndOfStream)
Ligne = Ftxt_Users.Readline
LigneDecoupee = split(Ligne,chr(59))
v_Niveau_1 = LigneDecoupee(0)
v_Niveau_2 = LigneDecoupee(1)
v_Niveau_3 = LigneDecoupee(2)
' ############## Declaration des Variables ##############
' > Declaration Variables pour l'AD <
v_Domaine = NomDomaine
' > Declaration Variables pour les OU <
v_OU_Dossiers_N_1 = "LDAP://OU=Niveau 1,OU=Dossiers,OU=01-Groupes," & oRoot.Get("defaultNamingContext")
v_OU_Dossiers_N_2 = "LDAP://OU=Niveau 2,OU=Dossiers,OU=01-Groupes," & oRoot.Get("defaultNamingContext")
v_OU_Dossiers_N_3 = "LDAP://OU=Niveau 3,OU=Dossiers,OU=01-Groupes," & oRoot.Get("defaultNamingContext")
' > Declaration Variables pour les Groupe <
v_Groupe_Niveau_1_Ecriture = "Dossier-" & v_Nom_Machine & "-N1-" & v_Niveau_1 & "-" & "Ecriture"
v_Groupe_Niveau_1_Lecture = "Dossier-" & v_Nom_Machine & "-N1-" & v_Niveau_1 & "-" & "Lecture"
v_Groupe_Niveau_1_Acces = "Dossier-" & v_Nom_Machine & "-N1-" & v_Niveau_1 & "-" & "Acces"
v_Groupe_Niveau_2_Ecriture = "Dossier-" & v_Nom_Machine & "-N2-" & v_Niveau_1 & "-" & v_Niveau_2 & "-" & "Ecriture"
v_Groupe_Niveau_2_Lecture = "Dossier-" & v_Nom_Machine & "-N2-" & v_Niveau_1 & "-" & v_Niveau_2 & "-" & "Lecture"
v_Groupe_Niveau_2_Acces = "Dossier-" & v_Nom_Machine & "-N2-" & v_Niveau_1 & "-" & v_Niveau_2 & "-" & "Acces"
v_Groupe_Niveau_3_Ecriture = "Dossier-" & v_Nom_Machine & "-N3-" & v_Niveau_1 & "-" & v_Niveau_2 & "-" & v_Niveau_3 & "-" & "Ecriture"
v_Groupe_Niveau_3_Lecture = "Dossier-" & v_Nom_Machine & "-N3-" & v_Niveau_2 & "-" & v_Niveau_3 & "-" & "Lecture"
v_Groupe_Niveau_3_Acces = "Dossier-" & v_Nom_Machine & "-N3-" & v_Niveau_1 & "-" & v_Niveau_2 & "-" & v_Niveau_3 & "-" & "Acces"
' > Declaration Variables pour les Dossiers <
Dim Act : Set Act = CreateObject("Wscript.Shell")
If v_Emplacement = 6 Then
Niveau1Path = v_Lecteur_Path & "\" & v_Niveau_1
Niveau2Path = v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2
Niveau3Path = v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & "\" & v_Niveau_3
End If
If v_Emplacement = 7 Then
Niveau1Path = "\\" & v_Nom_Machine & "\" & v_Lecteur_Path & "\" & v_Niveau_1
Niveau2Path = "\\" & v_Nom_Machine & "\" & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2
Niveau3Path = "\\" & v_Nom_Machine & "\" & v_Lecteur_Path & "\" & v_Niveau_1 & "\" & v_Niveau_2 & "\" & v_Niveau_3
End If
' ############## Appel des Procedures ##############
If v_Niveau_1 <> "" AND v_flag_Groupes_AD = 6 Then
Call Creation_Groupes_Niveau_1()
End If
If v_Niveau_2 <> "" AND v_flag_Groupes_AD = 6 Then
Call Creation_Groupes_Niveau_2()
End If
If v_Niveau_3 <> "" AND v_flag_Groupes_AD = 6 Then
Call Creation_Groupes_Niveau_3()
End If
If v_Niveau_2 <> "" AND v_flag_Groupes_AD = 6 Then
Call Niveau_2_All_Membre_De_Niveau_1_Acces()
End If
If v_Niveau_3 <> "" AND v_flag_Groupes_AD = 6 Then
Call Niveau_3_All_Membre_De_Niveau_2_Acces()
End If
If v_Niveau_1 <> "" AND v_Dernier_N1 <> v_Niveau_1 Then
Call Creation_Dossiers_N1()
v_Dernier_N1 = v_Niveau_1
End If
If v_Niveau_2 <> "" AND v_Dernier_N2 <> v_Niveau_2 Then
Call Creation_Dossiers_N2()
v_Dernier_N2 = v_Niveau_2
End If
If v_Niveau_3 <> "" Then
Call Creation_Dossiers_N3()
End If
Loop
vflag_fin = msgbox ("Opération Terminée." & VBcrlf & VBcrlf & "Vous pouvez consulter votre fichier de log pour plus de détails", 64, "Fin")
' ### Fin de la Creation ### |
Partager