' Thierry DEMAN (BY THE WAY) 'on error resume next ' ************** Initialisation des objets ***** Dim objFS, WshShell,WshNetwork 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 folders perms with "&LevelMax&" Levels" '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 Fichier level=level+1 Wscript.echo "Folder:" & TabStop & Folder.Path ShowPerm(Folder.path) Wscript.echo 'Wscript.quit If Len(Folder.path) < 254 and Level 0 Then For Each SubFolder In SubFolders SearchFolder(SubFolder) Next 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. ' Set oSD = oADsSecurityUtility.GetSecurityDescriptor(F, 1, 1) ' ' Get the Discrectionary ACL for the key. ' wscript.Echo "Owner "&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 "Perms="&Droits&" Account=" & wmiAce.Trustee&" level="&Cstr(Level) Next Set oDacl = Nothing Set oSD = Nothing Set oADsSecurityUtility = Nothing End Function ' ******* Fin des modules *********************