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

VBScript Discussion :

ayant droits sur des repertoires


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Novembre 2007
    Messages
    32
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 32
    Par défaut ayant droits sur des repertoires
    Bonjour à toutes et tous,

    Sur mon serveur 2003, sous AD, j'ai donc des groupes globaux et locaux. Je voulais savoir s'il existe une commande permettant de lister les ayant droits sur les répertoires du serveur, par ex:

    repertoire toto accès au groupe global toto
    repertoire tata accès au groupe global tata
    repertoire titi accès au groupe global titi et groupe global toto

    Merci de vos avis éclairés

    Philippe

  2. #2
    Membre chevronné
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 58

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Par défaut
    Salut,

    tu peux aller voir ce lien récent qui semble correspondre à tes attentes :

    http://www.developpez.net/forums/sho...d.php?t=432226

    A partir du script proposé par Fish Moon, j'ai fait celui ceci :

    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
    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
     
    SelDir = ""
    SelectDir
     
    Sub SelectDir
     
     
        SelDir = B("Choisissez un dossier")
     
        If IsNull(SelDir) Then
           MsgBox "Sélection invalide"
        else
           Affich
        End If
     
    End Sub
     
    Sub Affich
     
        Set objExplorer = WScript.CreateObject ("InternetExplorer.Application")
        objExplorer.Navigate "about:blank"
        objExplorer.ToolBar = 0
        objExplorer.StatusBar = 0
        objExplorer.Width = 600
        objExplorer.Height = 800
        objExplorer.Left = 20
        objExplorer.Top = 20
     
        ' Temporisation pour laisse le temps à IE de se charger
        Do While (objExplorer.Busy)
           Wscript.Sleep 200
        Loop
     
        ' Affichage de l'objet IE à l'ecran
        objExplorer.Visible = 1
        objExplorer.Document.WriteLn "<title>Logs</Title>"
        objExplorer.Document.WriteLn "<body bgcolor=#000066>"
        objExplorer.Document.WriteLn "<div><font size=2 face=""Arial"" color=white>Autorisations :</div>"
     
        ' Création de l'objet collection de repertoires
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFolder = objFSO.GetFolder(SelDir)
     
        ' Création de la collection des sous répertoires
        Set colSubfolders = objFolder.SubFolders
     
        ' Parcours des sous répertoires
        For Each objSubFolder in colSubfolders
    	strFolderName = objFolder & "\" & objSubfolder.Name
    	If intControlFlags = 33796 Then
    	   InHer = "Inheritance on"
    	Else
    	   InHer = "Inheritance off"
    	End If
    	objExplorer.Document.WriteLn "<br><font color=yellow>" & strFolderName  & " - " & InHer & "</font><br>"
    	' 
    	SE_DACL_PRESENT = &h4
    	ACCESS_ALLOWED_ACE_TYPE = &h0
    	ACCESS_DENIED_ACE_TYPE  = &h1
    	FILE_ALL_ACCESS         = &h1f01ff
    	FOLDER_ADD_SUBDIRECTORY = &h000004
    	FILE_DELETE             = &h010000
    	FILE_DELETE_CHILD       = &h000040
    	FOLDER_TRAVERSE         = &h000020
    	FILE_READ_ATTRIBUTES    = &h000080
    	FILE_READ_CONTROL       = &h020000
    	FOLDER_LIST_DIRECTORY   = &h000001
    	FILE_READ_EA            = &h000008
    	FILE_SYNCHRONIZE        = &h100000
    	FILE_WRITE_ATTRIBUTES   = &h000100
    	FILE_WRITE_DAC          = &h040000
    	FOLDER_ADD_FILE         = &h000002
    	FILE_WRITE_EA           = &h000010
    	FILE_WRITE_OWNER        = &h080000
     
    	' Instanciation de l'objet permettant de lire les DACLs
    	Set objWMIService = GetObject("winmgmts:")
    	Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
    	intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)
    	intControlFlags = objSD.ControlFlags
     
    	' Teste si l'objet peut admettre des paramètres de sécurité
    	If intControlFlags AND SE_DACL_PRESENT Then
     
    	   arrACEs = objSD.DACL
     
    	   ' Affiche les DACLs des sous repertoires
    		For Each objACE in arrACEs
    			' On affiche le DACL en cours et on met en évidence les autorisations existantes
     
    			If Len(objACE.Trustee.Domain) > 0 Then
    			   DomName = objACE.Trustee.Domain
    			Else
    			   DomName = "Local"
    			End If
    			XZne = "" 
    			If objACE.AccessMask AND FILE_ALL_ACCESS Then
    			   XZne = XZne & "FILE_ALL_ACCESS " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_APPEND_DATA Then
    		   	   XZne = XZne  & "FILE_APPEND_DATA " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_DELETE Then
    			   XZne = XZne  & "FILE_DELETE " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_DELETE_CHILD Then
    			   XZne = XZne  & "FILE_DELETE_CHILD " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_EXECUTE Then
    			   XZne = XZne  & "FILE_EXECUTE " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_READ_ATTRIBUTES Then
    			   XZne = XZne  & "FILE_READ_ATTRIBUTES " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_READ_CONTROL Then
    			   XZne = XZne  & "FILE_READ_CONTROL " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_READ_DATA Then
    			   XZne = XZne  & "FILE_READ_DATA " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_READ_EA Then
    			   XZne = XZne  & "FILE_READ_EA " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_SYNCHRONIZE Then
    			   XZne = XZne  & "FILE_SYNCHRONIZE " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_WRITE_ATTRIBUTES Then
    			   XZne = XZne  & "FILE_WRITE_ATTRIBUTES " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_WRITE_DAC Then
    			   XZne = XZne  & "FILE_WRITE_DAC " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_WRITE_DATA Then
    			   XZne = XZne  & "FILE_WRITE_DATA " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_WRITE_EA Then
    			   XZne = XZne  & "FILE_WRITE_EA " & "<br>"
    			End If
    			If objACE.AccessMask AND FILE_WRITE_OWNER Then
    			   XZne = XZne  & "FILE_WRITE_OWNER " & "<br>"
    			End If
     
    			objExplorer.Document.WriteLn DomName & " - " & objACE.Trustee.Name				  
     
    			If objACE.AceType = ACCESS_ALLOWED_ACE_TYPE Then
     
    			   objExplorer.Document.WriteLn "<br>"
    			   objExplorer.Document.WriteLn "<font color=cyan>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allowed</font><br>"
    			   objExplorer.Document.WriteLn "<font color=Red>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & Xzne & "</font>"
    			Else
    			   If objACE.AceType = ACCESS_DENIED_ACE_TYPE Then
    				  objExplorer.Document.WriteLn vbTab & "<font color=tomato> Denied</font><br>"
    			   End If
    			End If 	  
    		Next
     
    		VarUserDACL="NO"
     
    	Else
    		WScript.Echo "No DACL present in security descriptor"
    	End If
       Next
     
       objExplorer.Document.WriteLn vbTab & "<br><font color=tomato>----- FIN DE TRAITEMENT -----</font><br>"
     
    End Sub
     
    Function B(Msg)
    	On Error Resume Next
    	Dim a,f,i,w
    	Set a=WScript.CreateObject("Shell.Application")
     
    	Set f=a.BrowseForFolder(&H0&,Msg,&h1&)
    	B=f.ParentFolder.ParseName(f.Title).Path
     
    	If Err.Number<>0 Then
    		B=Null
    		If f.Title="Desktop" Then B=w.SpecialFolders("Desktop")
    		i=InStr(f.Title, ":")
    		If i>0 Then B=Mid(f.Title,i-1,2) & "\"
    	End If
    End Function
    en epérant que cela puisse t'aider.

    A++

  3. #3
    Membre averti
    Inscrit en
    Novembre 2007
    Messages
    32
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 32
    Par défaut ayant droits sur des repertoires
    Bonjour,

    J'ai récupéré ton script, et je l'ai testé. Ca répond tout a fait à mon besoin, plus qu'à l'adapter en fichier texte.

    Encore merci

    Philippe

  4. #4
    Membre chevronné
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 58

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Par défaut
    Je prévois de l'améliorer et effectivement d'en sortir un fichier texte.
    Ensuite l'idée serait de repartir du fichier et de réinjecter les sécurités...

    A++

  5. #5
    Membre chevronné
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 58

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Par défaut
    Etape 1 "Sortir un beau fichier" = Ok

    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
    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
     
    SelDir = ""
    SelectDir
     
    Sub SelectDir
     
        SelDir = B("Choisissez un dossier")
     
        If IsNull(SelDir) Then
           MsgBox "Sélection invalide"
        else
           Affich
        End If
     
    End Sub
     
    Sub Affich
     
        Set objExcel = CreateObject("Excel.Application")
        Set ObjFso = CreateObject("Scripting.FileSystemObject")
     
        objExcel.Visible = True
        objExcel.Workbooks.Add()
     
        objExcel.Cells(1, 1).Value = "Extraction des sécurités de " & SelDir & " du : " & FormatDateTime(Now, vbLongDate)
        objExcel.Cells(1, 1).Font.Bold = True
        objExcel.Cells(1, 1).Font.Size = 10
        objExcel.Cells(1, 1).Font.ColorIndex = 3
     
        ' Ajout des titres de colonnes
        objExcel.Cells(3, 1).Value = "Nom du partage"
        objExcel.Cells(3, 2).Value = "Héritage"
        objExcel.Cells(3, 3).Value = "Utilisateur"    
        objExcel.Cells(3, 4).Value = "Autorisation"
        objExcel.Cells(3, 5).Value = "Droits"
     
        i = 3
     
        ' Création de l'objet collection de repertoires
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFolder = objFSO.GetFolder(SelDir)
     
        ' Création de la collection des sous répertoires
        Set colSubfolders = objFolder.SubFolders
     
        ' Parcours des sous répertoires
        For Each objSubFolder in colSubfolders
    	    strFolderName = objFolder & "\" & objSubfolder.Name
     
    	    i = i + 1
    	    objExcel.Cells(i, 1).Value = strFolderName
     
    	    If intControlFlags = 33796 Then
    	       objExcel.Cells(i, 2).Value = "Inheritance on"
    	    Else
    	       objExcel.Cells(i, 2).Value = "Inheritance off"
    	    End If
     
       	    SE_DACL_PRESENT = &h4
    	    ACCESS_ALLOWED_ACE_TYPE = &h0
    	    ACCESS_DENIED_ACE_TYPE  = &h1
    	    FILE_ALL_ACCESS         = &h1f01ff
    	    FOLDER_ADD_SUBDIRECTORY = &h000004
    	    FILE_DELETE             = &h010000
    	    FILE_DELETE_CHILD       = &h000040
    	    FOLDER_TRAVERSE         = &h000020
    	    FILE_READ_ATTRIBUTES    = &h000080
    	    FILE_READ_CONTROL       = &h020000
    	    FOLDER_LIST_DIRECTORY   = &h000001
    	    FILE_READ_EA            = &h000008
    	    FILE_SYNCHRONIZE        = &h100000
    	    FILE_WRITE_ATTRIBUTES   = &h000100
    	    FILE_WRITE_DAC          = &h040000
    	    FOLDER_ADD_FILE         = &h000002
    	    FILE_WRITE_EA           = &h000010
    	    FILE_WRITE_OWNER        = &h080000
     
    	    ' Instanciation de l'objet permettant de lire les DACLs
    	    Set objWMIService = GetObject("winmgmts:")
    	    Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
    	    intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)
    	    intControlFlags = objSD.ControlFlags
     
    	    ' Teste si l'objet peut admettre des paramètres de sécurité
    	    If intControlFlags AND SE_DACL_PRESENT Then
     
    	       arrACEs = objSD.DACL
     
    	       ' Affiche les DACLs des sous repertoires
    		   For Each objACE in arrACEs
    		    	' On affiche le DACL en cours et on met en évidence les autorisations existantes
     
    			   If Len(objACE.Trustee.Domain) > 0 Then
    			      DomName = objACE.Trustee.Domain
    			   Else
    			      DomName = "Local"
    			   End If
     
    			   objExcel.Cells(i, 3).Value = DomName & " - " & objACE.Trustee.Name				  
     
    			   If objACE.AceType = ACCESS_ALLOWED_ACE_TYPE Then
    			      objExcel.Cells(i, 4).Value = "Allowed"
    			   Else
    			      If objACE.AceType = ACCESS_DENIED_ACE_TYPE Then
    				     objExcel.Cells(i, 4).Value = "Denied"
    			      End If
    			   End If 
     
    			   j = 4
     
    			   If objACE.AccessMask AND FILE_ALL_ACCESS Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_ALL_ACCESS"
    			   End If
    			   If objACE.AccessMask AND FILE_APPEND_DATA Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_APPEND_DATA"
    			   End If
    			   If objACE.AccessMask AND FILE_DELETE Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_DELETE"
    			   End If
    			   If objACE.AccessMask AND FILE_DELETE_CHILD Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_DELETE_CHILD"
    			   End If
    			   If objACE.AccessMask AND FILE_EXECUTE Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_EXECUTE"
    			   End If
    			   If objACE.AccessMask AND FILE_READ_ATTRIBUTES Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_READ_ATTRIBUTES"
    			   End If
    			   If objACE.AccessMask AND FILE_READ_CONTROL Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_READ_CONTROL"
    			   End If
    			   If objACE.AccessMask AND FILE_READ_DATA Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_READ_DATA"
    			   End If
    			   If objACE.AccessMask AND FILE_READ_EA Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_READ_EA"
    			   End If
    			   If objACE.AccessMask AND FILE_SYNCHRONIZE Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_SYNCHRONIZE"
    			   End If
    			   If objACE.AccessMask AND FILE_WRITE_ATTRIBUTES Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_WRITE_ATTRIBUTES"
    			   End If
    			   If objACE.AccessMask AND FILE_WRITE_DAC Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_WRITE_DAC"
    			   End If
    			   If objACE.AccessMask AND FILE_WRITE_DATA Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_WRITE_DATA"
    			   End If
    			   If objACE.AccessMask AND FILE_WRITE_EA Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_WRITE_EA"
    			   End If
    			   If objACE.AccessMask AND FILE_WRITE_OWNER Then
    		          j = j + 1	   
    			      objExcel.Cells(i, j).Value = "FILE_WRITE_OWNER"
    			   End If
    			   i = i + 1	  
    	       Next
          Else
    		   objExcel.Cells(i, 1).Value = "No DACL present in security descriptor"
    	  End If
       Next
     
       i = i + 1
       objExcel.Cells(i, 1).Value = "****** Fin du rapport ******"
       objExcel.Cells(i, 1).Font.Bold = True
       objExcel.Cells(i, 1).Font.Size = 10
       objExcel.Cells(i, 1).Font.ColorIndex = 3
     
    End Sub
     
    Function B(Msg)
    	On Error Resume Next
    	Dim a,f,i,w
    	Set a=WScript.CreateObject("Shell.Application")
     
    	Set f=a.BrowseForFolder(&H0&,Msg,&h1&)
    	B=f.ParentFolder.ParseName(f.Title).Path
     
    	If Err.Number<>0 Then
    		B=Null
    		If f.Title="Desktop" Then B=w.SpecialFolders("Desktop")
    		i=InStr(f.Title, ":")
    		If i>0 Then B=Mid(f.Title,i-1,2) & "\"
    	End If
    End Function
    La suite : "Etape 2 : réinjecter les sécurités" au prochain numéro...

    A++

  6. #6
    Membre averti
    Inscrit en
    Novembre 2007
    Messages
    32
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 32
    Par défaut ayant droits sur des repertoires
    Bonjour,

    Effectivement, ce serait l'idéal.Mais je ne maitrise pas suffisamment vbscript pour faire des tableaux excel comme toi. Ceci dit,il suffit de s'y mettre...Je vais me lancer pour le sortir en word.

    Merci
    Philippe

Discussions similaires

  1. [MCD]Gestion des droits sur des forums
    Par Vivian Pennel dans le forum Schéma
    Réponses: 1
    Dernier message: 01/05/2007, 16h43
  2. [C#] Prendre des droits sur des dossiers et sous dossiers
    Par raf_unl dans le forum Windows Forms
    Réponses: 4
    Dernier message: 19/03/2007, 13h44
  3. Droits sur un répertoire et limitation de quotas
    Par hat_et_m dans le forum Sécurité
    Réponses: 5
    Dernier message: 30/10/2006, 09h44
  4. Comment modifier les droits sur un répertoire ?
    Par rattlehead dans le forum Framework .NET
    Réponses: 4
    Dernier message: 19/10/2006, 14h42
  5. Problèmes de droits sur des images
    Par bedford dans le forum Sécurité
    Réponses: 2
    Dernier message: 11/08/2006, 09h26

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