IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Scripts/Batch Discussion :

Automatisation droit d'accès au dossier (d'un serveur domaine vers un serveur fichier)


Sujet :

Scripts/Batch

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2019
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Janvier 2019
    Messages : 2
    Par défaut Automatisation droit d'accès au dossier (d'un serveur domaine vers un serveur fichier)
    Bonjour, je suis actuellement en formation adulte d’administrateur réseau.

    Elle a commencé en décembre, et le centre de formation a jugé bon, de nous envoyer en stage après avoir vu très peu de chose, (5 semaine de cours 3 semaines de binaire 2 semaine et demis de remise a niveau de math (why) 3h sur VM debian 3h sur VM (installation d’active directory) et 2 semaine les couche Sisco ).

    Je suis donc en stage, et l’on me demandé de faire des testes sur deux VM (une servant de contrôleurs de domaines et l’autre le serveur de fichier (mise en place vendredi un serveur physique) dans le but d’automatiser un maximum les procédure, et de gagner du temps a l’installation.

    Actuellement l’active directory n’est pas optimal, tout les users et sont dans l’OU « user » aucune autre unité d’organisation, et aucun groupe.

    Depuis quelque jours, je me suis lancé dans des recherches pour le faire le plus rapidement. Donc par powershell. J’ai créé un script qui active « active directory », la sécurité de powershell, créer l’UO principal « Services » ensuite les UO des différents services dans l’uo pricipal, et dans ses uo, mes groupe ce formes. (cf la photo)

    mon script
    Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Import-Module ActiveDirectory
    Import-Module 'Microsoft.PowerShell.Security'
    #*****************************création des O U général*******************************************************
    New-ADOrganizationalUnit -Name "Services" -Path "dc=test,dc=lan"
    #*****************************création des O U par service***************************************************
    New-ADOrganizationalUnit -Name "DIR" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "RESP" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "ADM" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "APN" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "BE" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "CAQ" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "COMM" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "COMPTA" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "DEVECO" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "EEA" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "Elu" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "JEU" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "JUR" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "MP" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "OM" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "OT" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "PAT" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "PE" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "PROT" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "RH" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "RJ" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "THE" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "TIC" -Path "ou=services,dc=test,dc=lan"
    New-ADOrganizationalUnit -Name "URBA" -Path "ou=services,dc=test,dc=lan"
    ******************************Création groupe****************************************************************
    New-ADGroup -Name DIRECTION -GroupScope Global -GroupCategory Security -Path "ou=DIR,ou=services,dc=test,dc=lan"
    New-ADGroup -Name RESPONSABLE -GroupScope Global -GroupCategory Security -Path "ou=RESP,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_ADM -GroupScope Global -GroupCategory Security -Path "ou=ADM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_ADM -GroupScope Global -GroupCategory Security -Path "ou=ADM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_APN -GroupScope Global -GroupCategory Security -Path "ou=APN,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_APN -GroupScope Global -GroupCategory Security -Path "ou=APN,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_BE -GroupScope Global -GroupCategory Security -Path "ou=BE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_BE -GroupScope Global -GroupCategory Security -Path "ou=BE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_CAQ -GroupScope Global -GroupCategory Security -Path "ou=CAQ,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_CAQ -GroupScope Global -GroupCategory Security -Path "ou=CAQ,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_COMM -GroupScope Global -GroupCategory Security -Path "ou=COMM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_COMM -GroupScope Global -GroupCategory Security -Path "ou=COMM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_COMPTA -GroupScope Global -GroupCategory Security -Path "ou=COMPTA,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_COMPTA -GroupScope Global -GroupCategory Security -Path "ou=COMPTA,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_DEVECO -GroupScope Global -GroupCategory Security -Path "ou=DEVECO,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_DEVECO -GroupScope Global -GroupCategory Security -Path "ou=DEVECO,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_EEA -GroupScope Global -GroupCategory Security -Path "ou=EEA,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_EEA -GroupScope Global -GroupCategory Security -Path "ou=EEA,ou=services,dc=test,dc=lan"
    New-ADGroup -Name ELU -GroupScope Global -GroupCategory Security -Path "ou=Elu,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_JEU -GroupScope Global -GroupCategory Security -Path "ou=JEU,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_JEU -GroupScope Global -GroupCategory Security -Path "ou=JEU,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_JUR -GroupScope Global -GroupCategory Security -Path "ou=JUR,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_JUR -GroupScope Global -GroupCategory Security -Path "ou=JUR,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_MP -GroupScope Global -GroupCategory Security -Path "ou=MP,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_MP -GroupScope Global -GroupCategory Security -Path "ou=MP,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_OM -GroupScope Global -GroupCategory Security -Path "ou=OM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_OM -GroupScope Global -GroupCategory Security -Path "ou=OM,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_OT -GroupScope Global -GroupCategory Security -Path "ou=OT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_OT -GroupScope Global -GroupCategory Security -Path "ou=OT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_PAT -GroupScope Global -GroupCategory Security -Path "ou=PAT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_PAT -GroupScope Global -GroupCategory Security -Path "ou=PAT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_PE -GroupScope Global -GroupCategory Security -Path "ou=PE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_PE -GroupScope Global -GroupCategory Security -Path "ou=PE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_PROT -GroupScope Global -GroupCategory Security -Path "ou=PROT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_PROT -GroupScope Global -GroupCategory Security -Path "ou=PROT,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_RH -GroupScope Global -GroupCategory Security -Path "ou=RH,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_RH -GroupScope Global -GroupCategory Security -Path "ou=RH,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_RJ-GroupScope Global -GroupCategory Security -Path "ou=RJ,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_RJ -GroupScope Global -GroupCategory Security -Path "ou=RJ,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_THE -GroupScope Global -GroupCategory Security -Path "ou=THE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_THE -GroupScope Global -GroupCategory Security -Path "ou=THE,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_TIC -GroupScope Global -GroupCategory Security -Path "ou=TIC,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_TIC -GroupScope Global -GroupCategory Security -Path "ou=TIC,ou=services,dc=test,dc=lan"
    New-ADGroup -Name A_URBA -GroupScope Global -GroupCategory Security -Path "ou=URBA,ou=services,dc=test,dc=lan"
    New-ADGroup -Name R_URBA -GroupScope Global -GroupCategory Security -Path "ou=URBA,ou=services,dc=test,dc=lan"

    Nom : AD.PNG
Affichages : 468
Taille : 37,0 Ko

    Sur mon serveur fichier, j’ai créé un script .bat qui me permet de créer mes dossiers dans le serveur de fichier.


    Code Batch : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    MKDIR E:\ADM\R_Dossier\D_Dossier
    MKDIR E:\APN\R_Dossier\D_Dossier
    MKDIR E:\BE\R_Dossier\D_Dossier
    MKDIR E:\CAQ\R_Dossier\D_Dossier
    MKDIR E:\COMM\R_Dossier\D_Dossier
    MKDIR E:\COMPTA\R_Dossier\D_Dossier
    MKDIR E:\DEVECO\R_Dossier\D_Dossier
    MKDIR E:\MP\R_Dossier\D_Dossier
    MKDIR E:\OM\R_Dossier\D_Dossier
    MKDIR E:\OT\R_Dossier\D_Dossier
    MKDIR E:\PAT\R_Dossier\D_Dossier
    MKDIR E:\PE\R_Dossier\D_Dossier
    MKDIR E:\PROT\R_Dossier\D_Dossier
    MKDIR E:\RH\R_Dossier\D_Dossier
    MKDIR E:\THE\R_Dossier\D_Dossier
    MKDIR E:\TIC\R_Dossier\D_Dossier
    MKDIR E:\URBA\R_Dossier\D_Dossier


    Maintenant, je commence a avoir du mal, car j’aimerais réussir a automatiser, mes droit d’accès que dans « E:\Adm » seul les membres du groupe « A_Adm » aient le droit d’écriture et de lecture. Que mon groupe R_ADM est le droit de lecture et d’écriture sur le dossier R_dossier et A_Dossier Pour ce qui est du D_Dossier, ce n’ai pas un problème c’est un OU et dossier Direction (dans l’ad) qui lui a le droit de vu sur tout les dossier partager donc pas de prise de tête.

    Les utilisateurs eux seront mis a la mano dans dans leur groupe, a moins que quelqu’un ai une méthode pour créé un script. (je rappelle les users sont déjà créé l’active directory aussi, il va juste être mieux architecturé)

    Merci d'avance

  2. #2
    Membre émérite
    Homme Profil pro
    Développeur .NET en devenir
    Inscrit en
    Août 2017
    Messages
    549
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET en devenir
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2017
    Messages : 549
    Par défaut
    Bonjour,

    Pour définir les droits sur les dossiers tu peux utiliser la commande ICACLS.

    Par exemple voilà la commande pour définir les droits sur E:\ADM :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    icacls E:\ADM /grant:r A_Adm:(RX,M,D) /inheritance:r

    Concernant la création des dossiers, ton script pourrait se résumer à ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    setlocal enableextensions
    for %%A in (ADM APN BE CAQ COMM COMPTA DEVECO MP OM OT PAT PE PROT RH THE TIC URBA) do mkdir "E:\%%~A\R_Dossier\D_Dossier"

    Pour ajouter un utilisateur à un groupe, tu peux utiliser la commande NET GROUP : https://ss64.com/nt/net-useradmin.html

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2019
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Janvier 2019
    Messages : 2
    Par défaut
    Merci beaucoup pour la réponse, je vais pouvoir essaeyer des cette après-midi de donner les droit par groupe par le script que tu m'as donné.

    Pour ce qui est de la création de dossier et de sous dossier pour mon environnement de teste, j'avais trouvé la solution avec effectivement le MKdir en passant par un classeur avant pour ne pas avoir a répéter trop de fois la même chose pour en faire un CSV séparer par espace, ce qui as vite donné avec quelque remplacement sur notpad ++

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    MKDIR E:\ADM\R_Dossier\D_Dossier
    MKDIR E:\APN\R_Dossier\D_Dossier
    MKDIR E:\BE\R_Dossier\D_Dossier
    MKDIR E:\CAQ\R_Dossier\D_Dossier
    MKDIR E:\COMM\R_Dossier\D_Dossier
    MKDIR E:\COMPTA\R_Dossier\D_Dossier
    MKDIR E:\DEVECO\R_Dossier\D_Dossier
    MKDIR E:\MP\R_Dossier\D_Dossier
    MKDIR E:\OM\R_Dossier\D_Dossier
    MKDIR E:\OT\R_Dossier\D_Dossier
    MKDIR E:\PAT\R_Dossier\D_Dossier
    MKDIR E:\PE\R_Dossier\D_Dossier
    MKDIR E:\PROT\R_Dossier\D_Dossier
    MKDIR E:\RH\R_Dossier\D_Dossier
    MKDIR E:\THE\R_Dossier\D_Dossier
    MKDIR E:\TIC\R_Dossier\D_Dossier
    MKDIR E:\URBA\R_Dossier\D_Dossier
    mais si je décrypte bien par moi même ton script
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for %%A in (ADM APN BE CAQ COMM COMPTA DEVECO MP OM OT PAT PE PROT RH THE TIC URBA) do mkdir "E:\%%~A\R_Dossier\D_Dossier"
    For %%a in (ADM APN BE CAQ COMM COMPTA DEVECO MP OM OT PAT PE PROT RH THE TIC URBA) tout ceci représente mon sous dossier de niveau 1 et
    do mkdir "E:\%%~A\R_Dossier\D_Dossier" do donc fait dans les sous dossier de niveau 1 les sous dossier R_Dossier (sous dossier niveau 2) et D_Dossier (sous dossier niveau 3)

    En tout cas merci beaucoup je posterais un nouveau message si tout marche sur des roulette.

Discussions similaires

  1. [AC-2010] Tester les droits d'accès à un dossier
    Par Daejung dans le forum VBA Access
    Réponses: 7
    Dernier message: 08/02/2014, 15h58
  2. Réponses: 3
    Dernier message: 12/12/2013, 22h54
  3. Droits d'accès sur dossier
    Par Syrrus dans le forum VB.NET
    Réponses: 0
    Dernier message: 12/10/2010, 17h04
  4. [ASP.NET 2.0 + c#] Droits d'accès à un dossier partagé
    Par florent-k dans le forum ASP.NET
    Réponses: 4
    Dernier message: 14/09/2007, 09h50
  5. [APACHE] Modifié les droits d'accès à un dossier.
    Par will-scs dans le forum Apache
    Réponses: 1
    Dernier message: 26/08/2005, 22h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo