|
-
May 7th, 2010, 04:02 PM
#1
Retrieving remote share permissions - VB.net 2010
I've search tons of .net pages and all I can seem to find is vbs code for retrieving remote share permissions using WMI.
I've tried to convert this code to run on vb.net but don't seem to be getting anywhere.
Can anyone help - should I try to convert the below code or are there other methods I can use to retrieve the permissions. I can easily get the list of remote shares using win32_share but not the permissions 
Code:
strComputer = WScript.Arguments(0)
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from win32_share")
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
-
May 7th, 2010, 06:07 PM
#2
Re: Retrieving remote share permissions - VB.net 2010
Something like this:
Code:
'Correct the security for the share on NTFS-permission
Set objShell = CreateObject("Wscript.Shell")
objShell.run("cmd /c echo y| cacls " & path & sharename & " /t /g " & DLG_RWXD &_
":C " & DLG_RX & ":R "& """domain admins""" & ":F")
ADScriptoMatic
http://gallery.technet.microsoft.com...f-f160a6481767
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|