List FTP Virtual Directories Permissions in IIS 6.0

Posted on 2011-05-04
Last Modified: 2012-08-13
Hi Experts,

I need a vbscript to list all the users in the permissions tab from the ftp virtual directories regarding all the FTP sites in a server.

Bellow is a test but I cannot list the permissions and view the users that are configured in the permissions tab.
strComputer = "."
Const ForReading = 1
Const ForAppending = 8

Set objFS = CreateObject("Scripting.FileSystemObject")

If (objFS.FileExists("c:\userssite.txt")) Then

	Set filewrite=objFS.GetFile ("c:\userssite.txt")
End If

'Open output file  

Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objTextFile2 = objFSO2.OpenTextFile _
    ("c:\userssite.txt", ForAppending, True)
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpVirtualDirSetting")
	For Each objItem in colItems
		objTextFile2.WriteLine("Access Execute: " & objItem.AccessExecute & vbCrLf & "Access Flags: " & objItem.AccessFlags & "Access No Physical Directory: " & objItem.AccessNoPhysicalDir & vbCrLf & "Access No Remote Execute: " & objItem.AccessNoRemoteExecute & vbCrLf & "Access No Remote Execute: " & objItem.AccessNoRemoteExecute & vbCrLf & "Access No Remote Script: " & _
	        objItem.AccessNoRemoteScript & vbCrLf & "Access Read: " & objItem.AccessRead & vbCrLf & "Access Script: " & objItem.AccessScript & vbCrLf &  "Access Source: " & objItem.AccessSource & vbCrLf & "Access Source: " & _
		objItem.AccessSource & vbCrLf & "Access Source: " & objItem.AccessSource & vbCrLf & "Access Write: " & objItem.AccessWrite & vbCrLf & "Name: " & objItem.Name & vbCrLf & "Path: " & _
		objItem.Path & vbCrLf & "Path: " & objItem.Path)

	MsgBox "Finished " & strOutputFile

' List FTP Site Security Account Properties

Open in new window

Question by:pcfreaker
    1 Comment
    LVL 30

    Accepted Solution

    Does it need to be vbs? I have a BAT that does just that.

     @echo off

     set source=D:\Inetpub\ftproot
     set target=d:\%Permissions%.txt

     echo Compiling a directory listing
     dir /b /ad /s "%source%" > d:\tempenum.txt

     echo %date% at %time:~0,5% > %target%
    echo List of access rights >> %target%
    echo ==================== >> %target%
     for /F "tokens=*" %%* in (d:\tempenum.txt) do (
     echo Processing %%*
     cacls "%%*" >> %target%
    del d:\tempenum.txt
    notepad %target%

    Sample output
    Fri 05/06/2011 at  7:16
    List of access rights
    D:\Inetpub\ftproot\LocalUser\ftpuser_printsvcs\BUMU BUILTIN\Administrators:(OI)(CI)F
                                                                           SERVER\ftpuser_printsvcs:(OI)(CI)(special access:)


    D:\Inetpub\ftproot\NA\Public BUILTIN\Administrators:F
                                                                 NT AUTHORITY\SYSTEM:F
                                                                 NT AUTHORITY\SYSTEM:(OI)(CI)(IO)F
                                                                 NT AUTHORITY\Authenticated Users:C
                                                                 NT AUTHORITY\Authenticated Users:(OI)(CI)(IO)C
                                                                 BUILTIN\Users:(OI)(CI)(IO)(special access:)


    CACLS Abbreviations:
       CI - Container Inherit.
            The ACE will be inherited by directories.
       OI - Object Inherit.
            The ACE will be inherited by files.
       IO - Inherit Only.
            The ACE does not apply to the current file/directory.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    A web service ( is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now