we3kings
asked on
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.N ame)
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!
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.N
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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. :(
ASKER
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.
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.
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.
ASKER
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!
ASKER
Maybe this is a 500 point question. I will change points to 500.