#include <Array.au3>
#include <Constants.au3>
$Folder = FileSelectFolder("Choix d'un répertoire", "")
Global $FicOut = FileOpen("ListAcl.txt", 2)
_GetFilesFolder_Rekursiv($Folder, '*',$FicOut)
FileClose($FicOut)
Exit
Func _GetFilesFolder_Rekursiv($sPath, $sExt, $FicO)
Global $oFSO = ObjCreate('Scripting.FileSystemObject')
Global $strFiles = ''
_ShowSubFolders($oFSO.GetFolder($sPath),$sExt, $FicO)
EndFunc
Func _ShowSubFolders($Folder, $Ext, $FicO)
If Not IsDeclared("strFiles") Then Global $strFiles = ''
For $Subfolder In $Folder.SubFolders
FileWriteLine($FicO, $Subfolder.Path & '\')
_Acl($Subfolder.Path, $FicO)
_ShowSubFolders($Subfolder, $Ext, $FicO)
Next
EndFunc
Func _Acl($Repertoire, $FicO)
Local $foo = Run(@ComSpec & " /c cacls " & '"'&$Repertoire&'"', @TempDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $data
While True
$Data = StdoutRead($foo)
If @error Then ExitLoop
If $Data <> "" Then
FileWriteLine($FicO, $Data)
EndIf
WEnd
EndFunc
Le script fonctionne (et n'est pas terminé, il reste à construire une base de donnée pour faire des recherches), mais utiliser une fonction DOS (cacls en l'occurence) me gène un peu.. aussi, si quelqu'un avait une autre idée pour parvenir à lire les ACL d'un répertoire (en autoit, sans programme externe)...
j'ai cherché en vain pendant des jours....
Merci.
Modifié en dernier par Adenadels le dim. 14 févr. 2010 22:04, modifié 1 fois.
'================================
Set objshell= CreateObject("Wscript.shell")
Set voice = CreateObject("SAPI.Spvoice")
text = "Please wait....Enumerating Discretionary Access Control List for the folders"
'Creating Excel Instance:
'========================
Set excelinstance = CreateObject("Excel.application")
excelinstance.workbooks.add
excelinstance.visible = True
'Creating Columns:
'==================
excelinstance.cells(1,1).value = "Folders"
excelinstance.cells(1,2).value = "Domain"
excelinstance.cells(1,3).value = "Users/Groups"
'Starting from Second Row:
'=========================
m = 2
'Setting properties for columns:
'================================
Set range = excelinstance.range("A1","C1")
range.font.size = 12
range.font.bold = True
range.interior.colorindex = 6
range.font.name = "Times New Roman"
range.columnwidth = 20
'WMI Code:
'=========
strcomputer = "."
'Specify the path for the share:
'================================
strpathname = "E:\temp"
voice.Speak text
objshell.Popup "Please wait....Enumerating Discretionary Access Control List for the folders",5
'Calling Swbemservices Object:
'=============================
Set x = GetObject("winmgmts:\\" &strcomputer &"\root\cimv2")
Set folders =x.execquery("Associators of {Win32_Directory.Name='" & strpathname & "'} " & "Where AssocClass = Win32_Subdirectory " & "ResultRole = PartComponent")
For Each subfolder In folders
Getsubfolders strpathname
Next
'Sub Function for Recursive Enumeration of Folders:
'======================================
Sub Getsubfolders(strpathname)
Set folders1 = x.ExecQuery _
("Associators of {Win32_Directory.Name='" & strpathname & "'} " & "Where AssocClass = Win32_Subdirectory " & "ResultRole = PartComponent")
For Each subfolders1 In folders1
strpathname = subfolders1.name
excelinstance.cells(m,1) =strpathname
excelinstance.cells(m,1).columnwidth = 70
excelinstance.cells(m,1).font.name = "Times New Roman"
'Enumerating DACL's for each folder:
'====================================
Set objFolderSecuritySettings = _
x.Get("Win32_LogicalFileSecuritySetting='" & strpathName & "'")
returncode = objFolderSecuritySettings.GetSecurityDescriptor(SD)
If returncode = 0 Then
colAccess = SD.DACL
For Each objaccess In colaccess
excelinstance.cells(m,2) = objaccess.trustee.domain
excelinstance.cells(m,2).columnwidth = 40
excelinstance.cells(m,2).font.name = "Times New Roman"
excelinstance.cells(m,3) = objaccess.trustee.name
excelinstance.cells(m,3).columnwidth = 50
excelinstance.cells(m,3).font.name = "Times New Roman"
m = m + 1
Getsubfolders strpathname
Next
Else
excelinstance.cells(m,2).value = "DACL could not be retrieved"
excelinstance.cells(m,3).value = "DACL could not be retrieved"
End If
Next
End Sub