Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2958 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBS Avancé // Récupérer la liste des groupes de sécurité

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

VBS Avancé // Récupérer la liste des groupes de sécurité

n°2014967
mouataz
Posté le 06-08-2010 à 17:33:46  profilanswer
 

Bonjour,
Je suis entrain de développer une application pour l'attribution des accès à des ressources partagées dans un réseau d'entreprise et je rencontre des difficultés en ce moment, car il faut à un moment donné que l'application récupère les groupes de sécurité (GG et GL) des sous répértoires de la ressource partagée en utilisant un script VBS, C.A.D les groupes de l'onglet sécurité quand on fait un clique droit ==> propriété.
 
Quelqu'un peut m'aider SVP pour la réalisation du script VBS
 
je vous remercie par avance


Message édité par mouataz le 06-08-2010 à 18:56:48
mood
Publicité
Posté le 06-08-2010 à 17:33:46  profilanswer
 

n°2015931
mouataz
Posté le 11-08-2010 à 00:14:58  profilanswer
 

un premier pas vers une solution, un script que j'ai trouvé sur Microsoft Technet, ce code fonctionne dans une machine locale.
 

Code :
  1. '==========================================================================
  2. '
  3. ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
  4. '
  5. ' NAME: Folder Permission
  6. '
  7. ' AUTHOR:  Abdelkader, Amine
  8. ' DATE  : 10/03/2006
  9. '
  10. ' COMMENT: Create a file with the name of the folder in HTML format
  11. '
  12. '==========================================================================
  13. Const ForReading = 1, ForWriting = 2, ForAppending = 8
  14. Const FullAccessMask = 2032127, ModifyAccessMask = 1245631, WriteAccessMask = 118009
  15. Const ROAccessMask = 1179817
  16. strComputer = "."
  17. sParentFolder = InputBox("Please Enter folder to gather information on", "Parent Folder" )
  18. SParentFoldern=replace(sParentFolder,"\","" )
  19. SParentFoldern=replace(sParentFoldern,":","" )
  20. Set fso = CreateObject("Scripting.FileSystemObject" )
  21. 'File name Same As Folder Name without special Caracteres
  22. fullfilename=SParentFoldern&".html"
  23. 'WScript.echo fullfilename
  24. Set fsOut = fso.OpenTextFile(fullfilename, ForAppending, True)
  25. On Error Resume Next
  26. fsOut.Writeline ("<html>"&vbCr&"<head>"&vbCr&"<title>File Permission For Folder under &"& SParentFoldern&"</title>"&vbCr&"</head>" )
  27. strTableHead = "<table border=2 bordercolor='#000010' width='90%' id='Table1'>"
  28. fsOut.Writeline strTableHead
  29. fsOut.Writeline "<tr><td width='50%'>Folder</td>" & _
  30.    "<td width='50%'>User Name</td>"&_
  31.    "<td width='50%'>Permission</td></tr>"
  32. strTableFoot = "</table>"
  33. fsOut.Close
  34. ShowSubFolders FSO.GetFolder(sParentFolder),fullfilename
  35. OutputFolderInfo sParentFolder, fullfilename
  36. Set fsOut = fso.OpenTextFile(fullfilename, ForAppending, True)
  37. fsOut.Writeline strTableFoot
  38. fsOut.Close
  39. MsgBox "Done "
  40. WScript.Quit
  41. Public Sub OutputFolderInfo(FolderName , sOutfile)
  42. Const FullAccessMask = 2032127, ModifyAccessMask = 1245631, WriteAccessMask = 1180095
  43. Const ROAccessMask = 1179817
  44. Const ForReading = 1, ForWriting = 2, ForAppending = 8
  45. strComputer = "."
  46. 'Build the path to the folder because it requites 2 backslashes
  47. folderpath = Replace(FolderName, "\", "\\" )
  48. objectpath = "winmgmts:Win32_LogicalFileSecuritySetting.path='" & folderpath & "'"
  49. 'Get the security set for the object
  50. Set wmiFileSecSetting = GetObject(objectpath)
  51. 'verify that the get was successful
  52. RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
  53. If Err Then
  54.      MsgBox ("GetSecurityDescriptor failed" & vbCrLf & Err.Number & vbCrLf & Err.Description)
  55.      Err.Clear
  56. End If
  57. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
  58.     strComputer & "\root\cimv2" )
  59. Set colFolders = objWMIService.ExecQuery("SELECT * FROM Win32_Directory WHERE Name ='" & _
  60.     folderpath & "'" )
  61. For Each objFolder In colFolders
  62.    
  63.     ' Retrieve the DACL array of Win32_ACE objects.
  64.     DACL = wmiSecurityDescriptor.DACL
  65. Set fso = CreateObject("Scripting.FileSystemObject" )
  66. Set fsOut = fso.OpenTextFile(sOutfile, ForAppending, True)
  67.    
  68.     For Each wmiAce In DACL
  69.     ' Get Win32_Trustee object from ACE
  70.         Set Trustee = wmiAce.Trustee
  71.         fsOut.Writeline "<tr><td width='50%'>"&objFolder.Name&"</td>" & _
  72.    "<td width='50%'>"&Trustee.Domain&"\"&Trustee.Name&"</td>"
  73.         'fsOut.Write objFolder.Name & "," & Trustee.Domain & "\" & Trustee.Name & ","
  74.         FoundAccessMask = False
  75.         CustomAccessMask = Flase
  76.         While Not FoundAccessMask And Not CustomAccessMask
  77.             If wmiAce.AccessMask = FullAccessMask Then
  78.                 AccessType = "Full Control"
  79.                 FoundAccessMask = True
  80.             End If
  81.             If wmiAce.AccessMask = ModifyAccessMask Then
  82.                 AccessType = "Modify"
  83.                 FoundAccessMask = True
  84.             End If
  85.             If wmiAce.AccessMask = WriteAccessMask Then
  86.                 AccessType = "Read/Write Control"
  87.                 FoundAccessMask = True
  88.             End If
  89.             If wmiAce.AccessMask = ROAccessMask Then
  90.                 AccessType = "Read Only"
  91.                 FoundAccessMask = True
  92.             Else
  93.                 CustomAccessMask = True
  94.             End If
  95.         Wend
  96.      
  97.         If FoundAccessMask Then
  98.             'fsOut.Writeline AccessType
  99.             fsOut.Writeline "<td width='50%'>"&AccessType&"</td></tr>"
  100.         Else
  101.           fsOut.Writeline "<td width='50%'>Custom</td></tr>"
  102.             'fsOut.Writeline "Custom"
  103.         End If
  104.      
  105.     Next
  106.     Set fsOut = Nothing
  107.     Set fso = Nothing
  108. Next
  109. Set fsOut = Nothing
  110. Set fso = Nothing
  111. end Sub
  112. Sub ShowSubFolders (Folder,fname)
  113. On Error Resume Next
  114. For Each Subfolder in Folder.SubFolders
  115.      Call OutputFolderInfo(Subfolder.Path,fname)
  116.         Wscript.Echo Subfolder.Path
  117.         call ShowSubFolders (Subfolder,fname)
  118.     Next
  119. End Sub



Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBS Avancé // Récupérer la liste des groupes de sécurité

 

Sujets relatifs
VBS - Copier feuille Excel vers un autre classeurVBA Sélection aléatoire dans liste
récupérer des chiffres dans word sous excelExecuter une commande windowset récupérer le résultat
[RESOLU] Récupérer le path d'un projetliste de validation entre deux classeurs?[résolu]
[Shell/Windows] Récupérer la date de création d'un fichier[WebDev15] GUID Ldap ou comment récupérer de l'hexadecimale..
[Oracle10] Utiliser datapump avec une liste de tablesJee comment récupérer une variable dans un décorator struts1
Plus de sujets relatifs à : VBS Avancé // Récupérer la liste des groupes de sécurité


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR