I'm looking for a way to populate a ComboBox with a password protected list of network shares

VB.NET 2008 Express. I'm looking for a way to populate a ComboBox with a password protected list of network shares. The folders are  all on a N.A.S. Right now the program simply uses the provided username and password to open either (if the personal share option is selected) the user's personal share, or (if the group share is selected) the selected group share by mapping the x drive to it. The group share is selected from a combobox that is statically populated. This list needs to rather be populated with the above mentioned shares on the NAS.

I tried this:

        Dim sDir As String = "\\172.30.30.30\"
        Dim dDir As New DirectoryInfo(sDir)

        For Each folder As DirectoryInfo In dDir.GetDirectories
            ComboBox1.Items.Add(dDir.Name)
        Next

It gives the error:  The UNC path should be of the form \\server\share.
The shares are in the root of the NAS so i can't provide a share name... just for testing I followed the IP with a share name to see what would happen and it just froze. I'm assuming it's because i didn't provide a user or password. I need to populate the combobox with the share names in the password protected root.

Thanks!
we3kingsAsked:
Who is Participating?
 
itsmeandnobodyelseCommented:
If the computers are in a local LAN but not in a domain you can't retrieve the share names simply by reading from root.

I wouldn't make it too difficult. Why not define a known share for each computer which you would use as entry point to retrieve the names of the valid shares for combobox. those entries could be in a text file for example.
0
 
we3kingsAuthor Commented:
Thanks for the input. I already have a static list populating the combobox. I really need to get the list from the root because the folders list is bound to change. Also the NAS is a password protected Samba server. This creates the problem I am having accessing the root.

Maybe this is a 500 point question. I will change points to 500.
0
 
itsmeandnobodyelseCommented:
You might think of installing a service (or daemon if UNIX) at the server which returns a list of all shares on request. The interface to the client pc's typically would be a socket interface.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
we3kingsAuthor Commented:
Technically this is an SMB NAS not a real Linux SAMBA server so that option is not available on this thing. I'm afraid that the solution will lie in the VB code.  :(
0
 
we3kingsAuthor Commented:
For the record, the answer offered may have worked if we weren't using this particular configuration of devices, but it won't work on this... Thanks just the same.
0
 
itsmeandnobodyelseCommented:
I found the following site

    http://my.brandeis.edu/bboard/q-and-a-fetch-msg?msg_id=0000NC

which might give you a clue how to retrieve a list of shares from a Samba server.

If for example you can get the tool smbclient described in the above link for Windows you could get the list programmatically by

   system("smbclient -L //computer_name/  -I 192.168.0.77 > xxx.txt");

and then reading the xxx.txt to retrieve the names.
0
 
we3kingsAuthor Commented:
Technically there is no solution to this problem. You can't get the list from the smb NAS with a Windows workstation. SMBclient is not present on one. His method was possible but that's not what I want to do. I do like his suggestion: "don't make it too hard" which is what I often do. I resolve to leave the list static, but I will put the list in a text file that anyone may edit so they don't have to get into the code to do so... Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.