Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Modifier/adpater un script export ACL

4 réponses
Avatar
Lyes
Bonjour tout le monde,

J'ai trouvé un script qui me semble assez sympa permettant de faire un
export des ACL d'un volume vers excel et je souhaite le modifier afin qu'il
agisse récursivement le volume à auditer avec une profondeur de 3 sous
dossiers à partir de la racine.

Quelqu'un a-til une idée?
Ci-dessous le script à modifier:

strComputer = "."

Set objExcel = CreateObject("Excel.Application")
On Error resume Next

objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(2, 1).Value = "Login\Group Name"
objExcel.Cells(2, 1).Font.Bold = TRUE
objExcel.Cells(2, 2).Value = "Access Allowed\Denied"
objExcel.Cells(2, 2).Font.Bold = TRUE
objExcel.Cells(2, 3).Value = "Permission Assigned"
objExcel.Cells(2, 3).Font.Bold = TRUE
objExcel.WorkSheets(1).name = "Permissions List"

strFolderName = "R:\"

objExcel.Cells(1, 1).Value = strFolderName
SE_DACL_PRESENT = &h4
ACCESS_ALLOWED_ACE_TYPE = &h0
ACCESS_DENIED_ACE_TYPE = &h1

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")

Set objFolderSecuritySettings = objWMIService.Get _
("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")

intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)


intControlFlags = objSD.ControlFlags

If intControlFlags AND SE_DACL_PRESENT Then
arrACEs = objSD.DACL
X=3
For Each objACE in arrACEs

objExcel.Cells(x, 1).Value = _
objACE.Trustee.Domain & "\" & objACE.Trustee.Name
If objACE.AceType = ACCESS_ALLOWED_ACE_TYPE Then
objExcel.Cells(x, 2).Value = _
vbTab & "Allowed:"
ElseIf objACE.AceType = ACCESS_DENIED_ACE_TYPE Then
objExcel.Cells(x, 2).Value = _
vbTab & "Denied:"
End If
If objACE.AccessMask = "1245631" Then
objExcel.Cells(x, 3).Value = "Modify"
End If
If objACE.AccessMask = "1179785" Then
objExcel.Cells(x, 3).Value = "Read Only"
End If
If objACE.AccessMask = "1179817" Then
objExcel.Cells(x, 3).Value = "Read & Execute"
End If
If objACE.AccessMask = "2032127" Then
objExcel.Cells(x, 3).Value = "Full Control"
End If

X=X+1

Next
Else
WScript.Echo "No DACL present in security descriptor"
End If

Merci de votre aide

4 réponses

Avatar
Gilles LAURENT [MVP]
"Lyes" a écrit dans le message de
news:
| Bonjour tout le monde,

Bonjour,

| J'ai trouvé un script qui me semble assez sympa permettant de faire un
| export des ACL d'un volume vers excel et je souhaite le modifier
| afin qu'il agisse récursivement le volume à auditer avec une
| profondeur de 3 sous dossiers à partir de la racine.

Je n'ai toujours pas compris à quoi peut servir ce genre d'export
sachant que le document généré est difficilement exploitable. Si le but
est d'exporter puis d'importer les droits dans le cadre d'une migration
par exemple alors des outils plus adaptés sont disponibles. Que
souhaitez vous faire précisément ?

J'ai toutefois adapté le script comme ceci :
- récursivité
- profondeur
- export au format csv

Envoyez-moi un mail et j'attacherai ainsi le script en réponse.

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr
Avatar
Gilles LAURENT [MVP]
"Gilles LAURENT [MVP]" a écrit dans le message de
news:

[...]
| Envoyez-moi un mail et j'attacherai ainsi le script en réponse.

Transféré par mail à l'instant.
Tenez-nous au courant.

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr
Avatar
Thierry DEMAN [MVP]
Bonsoir,

j'ai réalisé un script qui réalise tout à fait cela !
Le format est très pratique à utiliser sous Excel...

cscript showPermsCsv.vbs /P:CheminLocalOuRéseau /L:3 >ListeDroits.TXT

En le chargeant de manière adéquate dans Excel, on peut
- filtrer les droits d'une personne ou d'un groupe précis
- filtrer les droits des groupes génériques (Tout le monde, Admin du
domaine, System,...)
- vérifier les droits sur chaque niveau, (1,2,3), s'il y a héritage ou pas
- Les droits les plus classiques (R,RW,RWC,Full) sont identifiés.

A bientôt,
http://www.faqexchange.info



----------------------- ShowPermsCsv.vbs---------------
' Thierry DEMAN (LE PERMIS INFORMATIQUE)
' Vers 1.2 Sortie compatible EXCEL (continue en cas d'erreur)

'on error resume next

' ************** Initialisation des objets *****
Dim objFS, WshShell,WshNetwork,Dossier,prop

Dim Level
level=-1
NewLine=chr(10)

SET wshshell = createObject ("Wscript.shell")
SET wshnetwork = Wscript.createObject ("Wscript.Network")
SET objFS=CreateObject ("Scripting.FileSystemObject")
' server = Wshshell.ExpandEnvironmentStrings("%COMPUTERNAME%")

'**** Récupération des paramètres ****

If WScript.Arguments.named.Count=0 Then
Wscript.echo("This tool need at least 1 argument"+Newline+"Usage:
ShowPerms.vbs Show perms on folders"+Newline+"Options /P:Path /L:Level")
wscript.quit(1)
End If

If WScript.Arguments.Named.exists("P") Then
Chemin=WScript.Arguments.Named.Item("P")
Else
Wscript.echo("This tool need at least /P argument"+Newline+"Usage:
ShowPerms.vbs"+Newline+"Options /P:Path")
wscript.quit(2)
End If

If WScript.Arguments.Named.exists("L") Then
LevelMax=Int(WScript.Arguments.Named.Item("L"))
IF LevelMax<0 Then
LevelMax=3
End if
Else
LevelMax=3
End If

'wscript.echo "Show perms of folder "&Chemin&" with "&LevelMax&" Levels"
wscript.echo "Dossier;Proprietaire;Compte;Droits;niveau"
'Wscript.QUIT

' *************** initialiation des variables *****

DIM Nb, I

' Set up global data.
TabStop = Chr(9)
NewLine = Chr(13)
Nb=0


' *************** Debut du programme principal *****

'wscript.echo "Recherche en cours"

SET oFolder = objFS.getFolder(Chemin)
SearchFolder(oFolder)

Wscript.QUIT

'**************** Fin du Programme principal *****

'******************* Debut des fonctions *****
Function SearchFolder(Folder)
Dim SubFolders, Files, oFile 'objets
Dim Fichierlevel=level+1

dossier=Folder.Path
ShowPerm(Folder.path)

'Wscript.echo
'Wscript.quit
If Len(Folder.path) < 254 and Level<LevelMax Then
Set SubFolders = Folder.SubFolders
on error resume next
If SubFolders.Count <> 0 Then
For Each SubFolder In SubFolders
SearchFolder(SubFolder)
Next
End If
if err.number<>0 Then
wscript.echo "Error on folder "&Dossier
err.clear
End if
End If

Level=level-1
End Function

Function ShowPerm(F)

Dim oAce 'As AccessControlEntry ' variable for the new ACE
Dim oSD 'As SecurityDescriptor ' variable for the Security Descriptor
of the object
Dim oDacl 'As AccessControlList ' variable for the DACL of the object
Dim oADsSecurityUtility 'As ADsSecurityUtility
Dim Trustee
'
' Create an ADsSecurityUtlity object.
'
Set oADsSecurityUtility = CreateObject("ADsSecurityUtility")
'
' Get the Security Descriptor for the given NTFS File path.
'
on error resume next
Set oSD = oADsSecurityUtility.GetSecurityDescriptor(F, 1, 1)
if err.number<>0 Then
wscript.echo "Error on folder "&Dossier
err.clear
End if
'
' Get the Discrectionary ACL for the key.
'
Prop=Osd.Owner

Set oDacl = oSD.DiscretionaryAcl
For each wmiAce in oDACL

' Trustee = wmiAce.Trustee
select Case int(wmiAce.AccessMask)
case 2032127
droits="FULL"
case 1179817
droits="RX"
case -1610612736
droits="RXe"
case 1245631
droits="RWX"
case 268435456
droits="FULL SUB ONLY"
case else
droits=Cstr(wmiAce.AccessMask)
end select
wscript.echo
dossier&";"&prop&";"&wmiAce.Trustee&";"&Droits&";"&Cstr(Level)
Next
Set oDacl = Nothing
Set oSD = Nothing
Set oADsSecurityUtility = Nothing

End Function

' ******* Fin des modules *********************




-------------------


"Gilles LAURENT [MVP]" a écrit dans le message de groupe de
discussion : u#
"Gilles LAURENT [MVP]" a écrit dans le message de
news:

[...]
| Envoyez-moi un mail et j'attacherai ainsi le script en réponse.

Transféré par mail à l'instant.
Tenez-nous au courant.

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr




Avatar
Gilles LAURENT [MVP]
"Thierry DEMAN [MVP]" a écrit dans le
message de
news:
| Bonsoir,

Bonsoir,

| j'ai réalisé un script qui réalise tout à fait cela !
| Le format est très pratique à utiliser sous Excel...
| cscript showPermsCsv.vbs /P:CheminLocalOuRéseau /L:3 >ListeDroits.TXT

Merci pour cette information.
J'espère que Lyes continue de suivre ce fil ;-)

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr