Problem with invoking WnetAddConnection2 from ASP.NET

V

varnk

I have a web application that is trying to establish a connection to a
shared drive by pinvoking WnetAddConnection2. This call works as expected
when I run it locally on my Windows XP system. However, when I try the same
call on Windows Server 2003, I get an error 85 indicating that the local
device is already in use. This occurs no matter which drive letter I try to
use for the local device. If I go to the command prompt and do a Net Use
with the same data supplied to WnetAddConnection2, the net use is successful.


Why am i able to map a drive using Net Use, but I cannot get the same
mapping to work calling WnetAddConnection2 in ASP.NET while running on
Windows Server 2003? This is very perplexing.
 
C

Cubaman

I have a web application that is trying to establish a connection to a
shared drive by pinvoking WnetAddConnection2.  This call works as expected
when I run it locally on my Windows XP system.  However, when I try the same
call on Windows Server 2003, I get an error 85 indicating that the local
device is already in use.  This occurs no matter which drive letter I try to
use for the local device.  If I go to the command prompt and do a Net Use
with the same data supplied to WnetAddConnection2, the net use is successful.

Why am i able to map a drive using Net Use, but I cannot get the same
mapping to work calling WnetAddConnection2 in ASP.NET while running on
Windows Server 2003?  This is very perplexing.

Not really sure, but take a look at the permission of the aspnet
process. When you map a drive from console, you're using you own
credentials, while aspnet hosting process should be running under some
other account with less privileges.
Best regards.
 
V

varnk

I am not sure what permissions I should check.

I would think that if it were a permission issue, the call to
WnetAddConnection2 would give me a permission error code and not "Local
Device is in use".

As a side note. I tried this on a clean install of Windoes 2003 server and
it works. Now I am not sure why it is not working on the original Windows
2003 server that I was testing on. I did not originally build the 2003
server that is not working correctly, so I don't know what could be causing
the problem.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top