Se connecter avec
S'enregistrer | Connectez-vous

Arborécence liste de droits

Dernière réponse : dans Programmation

Bonjours,

J'ai un code *.vbs qui me liste les dossiers et sous dossier dans un tableau dans une page html, mais maintenant on me demande qu'à coté de cette liste dans une nouvelle case dans le tableau je dresse la liste des droits de ce dossier
J'ai déjà galéré sur ce sujet à la 1ère étape, et là çà recommence car j'ai fais des recherche mais rien de concluant, en plus connaissant ce code depuis maintenant Lundi, je cherche à combiné c'est 2 codes dans les régle de l'art !!

CODE 1

  1. Const INT_MAX_LEVEL = 2
  2.  
  3. Dim ShellO: Set ShellO = CreateObject("WScript.Shell")
  4. Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
  5. Dim SListe: Dim Schemin
  6. 'Dossier à traiter
  7. Schemin = "C:\" 'Dossier à modifier
  8. 'Dossier Bureau de windows + "\"
  9. SListe = ShellO.SpecialFolders("Desktop")
  10. If Right(SListe, 1) <> "\" Then SListe = SListe & "\"
  11. 'Ouverture du fichier contenant l'arborescence du répertoire à traiter vers le Bureau
  12. Dim Fichier: Set Fichier = FSO.CreateTextFile(SListe & "Liste.html", 1, True)
  13.  
  14. strHTML=strHTML &"<center><h2><B><font color=red>Liste des Dossiers et Sous-Dossiers dans C:\ </font></B></h2></center>" & _
  15. "<table border='3' cellpadding='10' style='border-collapse: collapse; font size:11pt' bordercolor='#CCCCCC' width='100%' id='Table1'>" & _
  16. "<tr><td><strong>Chemin des Dossiers :</strong></td></tr>"
  17. 'Fichier.WriteLine (Schemin & "<br>")
  18. Fichier.WriteLine strHTML 'Ecrire la structure du Tableau en HTML
  19. ListerDossier Schemin, Fichier, 0 'Remplissage dynamique des données dans le Tableau
  20. Fichier.WriteLine "</table>" 'ici on ferme notre tableau par la balise </table>
  21. 'Fermeture du fichier contenant l'arborescence du répertoire à traiter
  22. Fichier.Close
  23.  
  24. Function ListerDossier(Schemin, Fichier, intLevel) 'Lister l'arborescence du dossier
  25. On Error Resume Next
  26. Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
  27. Dim ObjRep: Set ObjRep = FSO.GetFolder(Schemin) 'dossier
  28. Dim ObjSubRep: Set ObjSubRep = ObjRep.SubFolders 'sous-dossiers
  29. Dim ObjSubRepItem
  30. For Each ObjSubRepItem In ObjSubRep 'Traiter chaque sous-dossiers
  31. Fichier.WriteLine ("<tr><td><a href='" & ObjSubRepItem.Path & "'>" & ObjSubRepItem.Path & "</a></td></tr>") 'Ecrire le path dans les lignes du Tableau en HTML
  32. If intLevel < INT_MAX_LEVEL Then ListerDossier ObjSubRepItem.Path, Fichier, intLevel + 1 'traiter les sous-dossiers
  33. Fichier.WriteLine ObjSubFileItem.Path 'Ecrire le path dans la liste
  34. Next
  35. End Function


ET CODE 2


  1. SelDir = ""
  2. SelectDir
  3.  
  4. Sub SelectDir
  5.  
  6.  
  7. SelDir = B("Choisissez un dossier")
  8.  
  9. If IsNull(SelDir) Then
  10. MsgBox "Sélection invalide"
  11. else
  12. Affich
  13. End If
  14.  
  15. End Sub
  16.  
  17. Sub Affich
  18.  
  19. Set objExplorer = WScript.CreateObject ("InternetExplorer.Application")
  20. objExplorer.Navigate "about:blank"
  21. objExplorer.ToolBar = 0
  22. objExplorer.StatusBar = 0
  23. objExplorer.Width = 600
  24. objExplorer.Height = 800
  25. objExplorer.Left = 20
  26. objExplorer.Top = 20
  27.  
  28. ' Temporisation pour laisse le temps à IE de se charger
  29. Do While (objExplorer.Busy)
  30. Wscript.Sleep 200
  31. Loop
  32.  
  33. ' Affichage de l'objet IE à l'ecran
  34. objExplorer.Visible = 1
  35. objExplorer.Document.WriteLn "<title>Logs</Title>"
  36. objExplorer.Document.WriteLn "<body bgcolor=#000066>"
  37. objExplorer.Document.WriteLn "<div><center><font size=2 face=""Arial"" color=white> Autorisations :</div></center>"
  38.  
  39. ' Création de l'objet collection de repertoires
  40. Set objFSO = CreateObject("Scripting.FileSystemObject")
  41. Set objFolder = objFSO.GetFolder(SelDir)
  42.  
  43. ' Création de la collection des sous répertoires
  44. Set colSubfolders = objFolder.SubFolders
  45.  
  46. ' Parcours des sous répertoires
  47. For Each objSubFolder in colSubfolders
  48. strFolderName = objFolder & "\" & objSubfolder.Name
  49. If intControlFlags = 33796 Then
  50. InHer = "Heritage on"
  51. Else
  52. InHer = "Heritage off"
  53. End If
  54. objExplorer.Document.WriteLn "<br><font color=yellow>" & strFolderName & " - " & InHer & "</font><br>"
  55. '
  56. SE_DACL_PRESENT = &h4
  57. ACCESS_ALLOWED_ACE_TYPE = &h0
  58. ACCESS_DENIED_ACE_TYPE = &h1
  59. FILE_ALL_ACCESS = &h1f01ff
  60. FOLDER_ADD_SUBDIRECTORY = &h000004
  61. FILE_DELETE = &h010000
  62. FILE_DELETE_CHILD = &h000040
  63. FOLDER_TRAVERSE = &h000020
  64. FILE_READ_ATTRIBUTES = &h000080
  65. FILE_READ_CONTROL = &h020000
  66. FOLDER_LIST_DIRECTORY = &h000001
  67. FILE_READ_EA = &h000008
  68. FILE_SYNCHRONIZE = &h100000
  69. FILE_WRITE_ATTRIBUTES = &h000100
  70. FILE_WRITE_DAC = &h040000
  71. FOLDER_ADD_FILE = &h000002
  72. FILE_WRITE_EA = &h000010
  73. FILE_WRITE_OWNER = &h080000
  74.  
  75. ' Instanciation de l'objet permettant de lire les DACLs
  76. Set objWMIService = GetObject("winmgmts:")
  77. Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
  78. intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)
  79. intControlFlags = objSD.ControlFlags
  80.  
  81. ' Teste si l'objet peut admettre des paramètres de sécurité
  82. If intControlFlags AND SE_DACL_PRESENT Then
  83.  
  84. arrACEs = objSD.DACL
  85.  
  86. ' Affiche les DACLs des sous repertoires
  87. For Each objACE in arrACEs
  88. ' On affiche le DACL en cours et on met en évidence les autorisations existantes
  89.  
  90. If Len(objACE.Trustee.Domain) > 0 Then
  91. DomName = objACE.Trustee.Domain
  92. Else
  93. DomName = "Local"
  94. End If
  95. XZne = "<br>"
  96. If objACE.AccessMask AND FILE_ALL_ACCESS Then
  97. XZne = XZne & "Contrôle total" & "<br>"
  98. End If
  99. If objACE.AccessMask AND FILE_APPEND_DATA Then
  100. XZne = XZne & "Création de dossier / Ajout de données" & "<br>"
  101. End If
  102. If objACE.AccessMask AND FILE_DELETE Then
  103. XZne = XZne & "Suppression" & "<br>"
  104. End If
  105. If objACE.AccessMask AND FILE_DELETE_CHILD Then
  106. XZne = XZne & "Suppression de sous-dossier & fichier" & "<br>"
  107. End If
  108. If objACE.AccessMask AND FILE_EXECUTE Then
  109. XZne = XZne & "Parcours du dossier / éxécuter le fichier" & "<br>"
  110. End If
  111. If objACE.AccessMask AND FILE_READ_ATTRIBUTES Then
  112. XZne = XZne & "Attributs de lecture" & "<br>"
  113. End If
  114. If objACE.AccessMask AND FILE_READ_CONTROL Then
  115. XZne = XZne & "Autorisation de lecture" & "<br>"
  116. End If
  117. If objACE.AccessMask AND FILE_READ_DATA Then
  118. XZne = XZne & "Liste du dossier / lecture de données" & "<br>"
  119. End If
  120. If objACE.AccessMask AND FILE_READ_EA Then
  121. XZne = XZne & "Lecture des attributs étendus" & "<br>"
  122. End If
  123. If objACE.AccessMask AND FILE_SYNCHRONIZE Then
  124. XZne = XZne & "Synchronize" & "<br>"
  125. End If
  126. If objACE.AccessMask AND FILE_WRITE_ATTRIBUTES Then
  127. XZne = XZne & "Attributs d'ecriture" & "<br>"
  128. End If
  129. If objACE.AccessMask AND FILE_WRITE_DAC Then
  130. XZne = XZne & "Modification des autorisations" & "<br>"
  131. End If
  132. If objACE.AccessMask AND FILE_WRITE_DATA Then
  133. XZne = XZne & "Création de Fichier / écriture de données" & "<br>"
  134. End If
  135. If objACE.AccessMask AND FILE_WRITE_EA Then
  136. XZne = XZne & "Ecriture d'attributs étendus" & "<br>"
  137. End If
  138. If objACE.AccessMask AND FILE_WRITE_OWNER Then
  139. XZne = XZne & "Appropriation" & "<br>"
  140. End If
  141.  
  142. XZne = XZne & "<br>"
  143.  
  144. objExplorer.Document.WriteLn DomName & " - " & objACE.Trustee.Name
  145.  
  146. If objACE.AceType = ACCESS_ALLOWED_ACE_TYPE Then
  147.  
  148. objExplorer.Document.WriteLn "<br>"
  149. objExplorer.Document.WriteLn "<font color=cyan>      Autorisé à : </font><br>"
  150. objExplorer.Document.WriteLn "<font color=Red>            " & Xzne & "</font>"
  151. Else
  152. If objACE.AceType = ACCESS_DENIED_ACE_TYPE Then
  153. objExplorer.Document.WriteLn vbTab & "<br><font color=tomato>      Vous est interdit : </font><br>"
  154. objExplorer.Document.WriteLn "<font color=Red>            " & Xzne & "</font>"
  155.  
  156. End If
  157. End If
  158. Next
  159.  
  160. VarUserDACL="NO"
  161.  
  162. Else
  163. WScript.Echo "No DACL present in security descriptor"
  164. End If
  165. Next
  166.  
  167. objExplorer.Document.WriteLn vbTab & "<br><font color=tomato>----- FIN DE TRAITEMENT -----</font><br>"
  168.  
  169. End Sub
  170.  
  171. Function B(Msg)
  172. On Error Resume Next
  173. Dim a,f,i,w
  174. Set a=WScript.CreateObject("Shell.Application")
  175.  
  176. Set f=a.BrowseForFolder(&H0&,Msg,&h1&)
  177. B=f.ParentFolder.ParseName(f.Title).Path
  178.  
  179. If Err.Number<>0 Then
  180. B=Null
  181. If f.Title="Desktop" Then B=w.SpecialFolders("Desktop")
  182. i=InStr(f.Title, ":")
  183. If i>0 Then B=Mid(f.Title,i-1,2) & "\"
  184. End If
  185. End Function

Autres pages sur : arborecence liste droits

Lassé par la pub ? Créez un compte
Lassé par la pub ? Créez un compte