I've been thinking to create an app that lists the shared folders from a server, ie: I input the host and then it will give me the list of shared folders from that server, plus give me the users and groups that can access that folder.
I know I can get the list of shared folders from:
Registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanServer\Shares
WMI:
SELECT * FROM win32_share
And the security from:
Registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanServer\Shares\Security
More info about it:
http://technet.microsoft.com/en-us/library/cc781716%28v=ws.10%29.aspx
I can get that information by opening a remote share like \\10.10.10.5 and it will shows on explorer the list of shared folders, if I have access then I can simple do a right click and hit properties, then it will give me what I need, but I need this programatically.
Local Solution: http://www.indented.co.uk/2009/02/19/reading-ntfs-and-share-security-with-vbscript/
Remote Solution:
strComputer = WScript.Arguments(0)
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from win32_share where type='0'")
For Each i In colItems
strDir = i.path
WScript.Echo "Share Name: " & i.name
strDir = Replace(strDir,"\","\\")
Set colItems = objWMI.ExecQuery("Select * from win32_logicalFileSecuritySetting WHERE Path='" & strDir & "'",,48)
for each objItem in colItems
If objItem.GetSecurityDescriptor(wmiSecurityDescriptor) Then
WScript.Echo "GetSecurityDescriptor failed"
DisplayFileSecurity = False
WScript.Quit
End If
For each wmiAce in wmiSecurityDescriptor.DACL
strACE = wmiAce.Trustee.Domain & "\" & wmiAce.Trustee.Name
'If instr(strACE,".") then
wscript.echo " " & strACE
'end If
Next
Next
Next