CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Posts
    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

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured