Urgent VBScript needed

Author Message
rmclare3

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 2/22/2005
  • Location: United Kingdom
  • Status: offline
Urgent VBScript needed Tuesday, February 22, 2005 9:50 PM (permalink)
0
Anyone got a quick answer to this -
I need a script to create a file which contains all usernames who have access to folders in a directory. Please [V]
 
#1
    Bushmen

    • Total Posts : 122
    • Scores: 0
    • Reward points : 0
    • Joined: 2/4/2005
    • Location:
    • Status: offline
    Re: Urgent VBScript needed Wednesday, February 23, 2005 2:08 AM (permalink)
    0
    rmclare3

    I have not done this myself, but i've done a bit of research and i came accross the following script on a forum.

    Now just before i post the code, the guys who wrote this really went into details and via wscript.echo provides a lot of information. If you play with the script, take a lot of the information that you don't need, then you'll get what you want.

    I believe you are interested in the sections where it says:

    WScript.Echo i & ". Trustee Name: " & wmiTrustee.Name

    Ok, here goes
    =========================================================================================
    Option Explicit

    Dim CONTROL_FLAGS ' ControlFlags values
    Dim ACCESS_MASK ' AccessMask values
    Dim ACE_FLAGS ' AceFlags values
    Dim ACE_TYPE ' AceType values
    Dim Key ' Dictionary object key
    Dim blnFirstValue ' Flag for formatting
    Dim i ' Counter
    Dim intRetVal ' Return value
    Dim strComputer ' Target computer name
    Dim strFolder ' Target folder (or file) name
    Dim wmiServices ' SWbemServices object
    Dim wmiSecuritySettings ' Win32_LogicalFileSecuritySetting
    Dim wmiSecurityDescriptor ' Win32_SecurityDescriptor
    Dim wmiOwner ' Win32_Trustee
    Dim wmiAce ' Win32_ACE
    Dim wmiTrustee ' Win32Trustee
    Dim arrDacl ' DACL array
    Dim arrSacl ' SACL array

    strComputer = "dell610" ' Target computer name
    strFolder = "c:\windows" ' Fully qualified file or folder name

    Set CONTROL_FLAGS = CreateObject("Scripting.Dictionary")
    CONTROL_FLAGS.Add "SE_OWNER_DEFAULTED", 1
    CONTROL_FLAGS.Add "SE_GROUP_DEFAULTED", 2
    CONTROL_FLAGS.Add "SE_DACL_PRESENT", 4
    CONTROL_FLAGS.Add "SE_DACL_DEFAULTED", 8
    CONTROL_FLAGS.Add "SE_SACL_PRESENT", 16
    CONTROL_FLAGS.Add "SE_SACL_DEFAULTED", 32
    CONTROL_FLAGS.Add "SE_DACL_AUTO_INHERIT_REQ", 256
    CONTROL_FLAGS.Add "SE_SACL_AUTO_INHERIT_REQ", 512
    CONTROL_FLAGS.Add "SE_DACL_AUTO_INHERITED", 1024
    CONTROL_FLAGS.Add "SE_SACL_AUTO_INHERITED", 2048
    CONTROL_FLAGS.Add "SE_DACL_PROTECTED", 4096
    CONTROL_FLAGS.Add "SE_SACL_PROTECTED", 8192
    CONTROL_FLAGS.Add "SE_SELF_RELATIVE", 32768

    Set ACCESS_MASK = CreateObject("Scripting.Dictionary")
    ACCESS_MASK.Add "FILE_LIST_DIRECTORY", 1
    ACCESS_MASK.Add "FILE_ADD_FILE", 2
    ACCESS_MASK.Add "FILE_ADD_SUBDIRECTORY", 4
    ACCESS_MASK.Add "FILE_READ_EA", 8
    ACCESS_MASK.Add "FILE_WRITE_EA", 16
    ACCESS_MASK.Add "FILE_TRAVERSE", 32
    ACCESS_MASK.Add "FILE_DELETE_CHILD", 64
    ACCESS_MASK.Add "FILE_READ_ATTRIBUTES", 128
    ACCESS_MASK.Add "FILE_WRITE_ATTRIBUTES", 256
    ACCESS_MASK.Add "DELETE", 65536
    ACCESS_MASK.Add "READ_CONTROL", 131072
    ACCESS_MASK.Add "WRITE_DAC", 262144
    ACCESS_MASK.Add "WRITE_OWNER", 524288
    ACCESS_MASK.Add "SYNCHRONIZE", 1048576

    Set ACE_FLAGS = CreateObject("Scripting.Dictionary")
    ACE_FLAGS.Add "OBJECT_INHERIT_ACE", 1
    ACE_FLAGS.Add "CONTAINER_INHERIT_ACE", 2
    ACE_FLAGS.Add "NO_PROPAGATE_INHERIT_ACE", 4
    ACE_FLAGS.Add "INHERIT_ONLY_ACE", 8
    ACE_FLAGS.Add "INHERITED_ACE", 16
    ACE_FLAGS.Add "SUCCESSFUL_ACCESS_ACE_FLAG", 32
    ACE_FLAGS.Add "FAILED_ACCESS_ACE_FLAG", 64

    Set ACE_TYPE = CreateObject("Scripting.Dictionary")
    ACE_TYPE.Add 0, "Access Allowed"
    ACE_TYPE.Add 1, "Access Denied"
    ACE_TYPE.Add 2, "Audit"

    '********************
    '* CALLOUT A
    '********************
    ' Connect to WMI on target computer
    Set wmiServices = GetObject _
    ("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer)

    ' Get target folder's (or file's) security settings
    Set wmiSecuritySettings = wmiServices.Get _
    ("Win32_LogicalFileSecuritySetting.Path='" & strFolder & "'")

    WScript.Echo "Win32_LogicalFileSecuritySettings"
    WScript.Echo "================================="
    WScript.Echo "Caption: " & wmiSecuritySettings.Caption
    WScript.Echo "ControlFlags: " & wmiSecuritySettings.ControlFlags
    WScript.Echo "Description: " & wmiSecuritySettings.Description
    WScript.Echo "OwnerPermissions: " & wmiSecuritySettings.OwnerPermissions
    WScript.Echo "Path: " & wmiSecuritySettings.Path
    WScript.Echo "SettingID: " & wmiSecuritySettings.SettingID
    WScript.Echo

    '********************
    '* CALLOUT B
    '********************
    ' Get target folder's (or file's) Security Descriptor
    intRetVal = wmiSecuritySettings.GetSecurityDescriptor(wmiSecurityDescriptor)

    ' Security Descriptor's Owner represented by instance of Win32_Trustee
    Set wmiOwner = wmiSecurityDescriptor.Owner

    WScript.Echo "Win32_SecurityDescriptor"
    WScript.Echo "------------------------"
    WScript.Echo "Owner Name: " & wmiOwner.Name
    WScript.Echo "Owner SIDString: " & wmiOwner.SIDString
    WScript.Echo "Owner Domain: " & wmiOwner.Domain

    '********************
     
    #2
      token

      • Total Posts : 1917
      • Scores: 0
      • Reward points : 0
      • Joined: 1/14/2005
      • Location:
      • Status: offline
      Re: Urgent VBScript needed Wednesday, February 23, 2005 11:31 AM (permalink)
      0
      "......who have access to folders in a directory". You mean all users who have access to sub-folders ONLY in a directory ? What about files ?
       
      #3
        rmclare3

        • Total Posts : 5
        • Scores: 0
        • Reward points : 0
        • Joined: 2/22/2005
        • Location: United Kingdom
        • Status: offline
        Re: Urgent VBScript needed Sunday, March 06, 2005 11:34 PM (permalink)
        0
        quote:
        Originally posted by rmclare3

        Anyone got a quick answer to this -
        I need a script to create a file which contains all usernames who have access to folders in a directory. Please [V]

         
        #4
          rmclare3

          • Total Posts : 5
          • Scores: 0
          • Reward points : 0
          • Joined: 2/22/2005
          • Location: United Kingdom
          • Status: offline
          Re: Urgent VBScript needed Sunday, March 06, 2005 11:41 PM (permalink)
          0
          Thanks for your reply and apologies for not replying untill now - got pulled of that job.
          I'm looking at script now and as you say it's pretty detailed. I'll give ut a try but it will test my limited skills I'm sure.
          Thanks again.

          Bob
           
          #5
            token

            • Total Posts : 1917
            • Scores: 0
            • Reward points : 0
            • Joined: 1/14/2005
            • Location:
            • Status: offline
            Re: Urgent VBScript needed Monday, March 07, 2005 7:36 AM (permalink)
            0
            ouch.. sorry to hear that, hoepfully it was related to the question you posted :\

             
            #6
              Bushmen

              • Total Posts : 122
              • Scores: 0
              • Reward points : 0
              • Joined: 2/4/2005
              • Location:
              • Status: offline
              Re: Urgent VBScript needed Monday, March 07, 2005 11:30 AM (permalink)
              0
              token

              did you have a simpler script to do this?

              just for my own knowledge

              bushmen
               
              #7
                token

                • Total Posts : 1917
                • Scores: 0
                • Reward points : 0
                • Joined: 1/14/2005
                • Location:
                • Status: offline
                Re: Urgent VBScript needed Monday, March 07, 2005 12:18 PM (permalink)
                0
                Not really, most of our security related tasks are accomplished through the use of security groups and they don't change often once they have been in place. Don't really have the need to create such scripts (yet).

                 
                #8

                  Online Bookmarks Sharing: Share/Bookmark

                  Jump to:

                  Current active users

                  There are 0 members and 1 guests.

                  Icon Legend and Permission

                  • New Messages
                  • No New Messages
                  • Hot Topic w/ New Messages
                  • Hot Topic w/o New Messages
                  • Locked w/ New Messages
                  • Locked w/o New Messages
                  • Read Message
                  • Post New Thread
                  • Reply to message
                  • Post New Poll
                  • Submit Vote
                  • Post reward post
                  • Delete my own posts
                  • Delete my own threads
                  • Rate post

                  2000-2012 ASPPlayground.NET Forum Version 3.9