Connecting to network shares

J

JohnFol

I have some code working that uses the API WNetAddConnection2. The code is
used from a Windows Form and on my PC it works. If I package the code and
deploy to a server the code fails with an error

"The following exception has occured: Unable to connect network drive. Win32
error code is: 67 (The network name cannot be found.)"

This is when I am logged on as the administrator of the local machine. I
thought it might be the fact I am not authenticated by a domain (whereas on
my PC I am). However, if on that machine I do a simple Start\Run and enter
the exact same IP\Share name I get prompted for the Username / password.
When entered as per the WNetAddConnection2 parameters I can see the files
without problem.


So, I am really getting stuck for ideas.


PS I did try this a few days back as a Windows Service and had "other"
problems, hence why it's now a Windows Forms exe.
 
K

Ken Tucker [MVP]

Hi,

Maybe this will help.
http://www.dotnet247.com/247reference/msgs/28/144136.aspx

Ken
------------------
I have some code working that uses the API WNetAddConnection2. The code is
used from a Windows Form and on my PC it works. If I package the code and
deploy to a server the code fails with an error

"The following exception has occured: Unable to connect network drive. Win32
error code is: 67 (The network name cannot be found.)"

This is when I am logged on as the administrator of the local machine. I
thought it might be the fact I am not authenticated by a domain (whereas on
my PC I am). However, if on that machine I do a simple Start\Run and enter
the exact same IP\Share name I get prompted for the Username / password.
When entered as per the WNetAddConnection2 parameters I can see the files
without problem.


So, I am really getting stuck for ideas.


PS I did try this a few days back as a Windows Service and had "other"
problems, hence why it's now a Windows Forms exe.
 
J

JohnFol

Hi Ken, thanks for the pointer.

If I use a made up username / password I get a boolean True for the
LogonUser function, but get a ret value of 126
If I continue to step through I get a "New Identity" of "Guest" under a
local machine.



I need to check the domain for the account I use to connect with before
trying "for real", but many thanks for the assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top