dimanche 1 mars 2015

WinNT - Get all users that have access to a fileshare - VB.NET

My problem : I'm searching to find all users or groups that have access to a fileshare in WinNT and waht is their rights to this fileshare.


I can find all files shared on a machine like this :



Function WinNT_Share_List()
Dim ShareSrvObj = GetObject("WinNT://" & Environment.MachineName & "/LANMANSERVER")
Dim str = ""
For Each ShareObj In ShareSrvObj
str = str & ShareObj.Name & vbNewLine
Next
Dim ret As String()
ret = str.Split(New Char() {vbCr})
Return ret
End Function


but i can't find all "pocessors"... i've tried thie too :



Dim Share = GetObject("WinNT://" & Environment.MachineName & "/LANMANSERVER/MyShare")
Dim Array(2) As Object
Array(0) = "user"
Array(1) = "group"
Share.Filter = Array
Dim DisplayString = ""
For Each User In Share
DisplayString = DisplayString & User.Name & vbNewLine
Next
MsgBox(DisplayString)


but it's not working, it's just crash...


Thanks for your help !


PS: sorry if i have made some faults, i'm not a pro in english, i'm french :)


Aucun commentaire:

Enregistrer un commentaire