From: varnk on

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.


From: Cubaman on
On Jul 27, 7:31 pm, varnk <va...(a)discussions.microsoft.com> wrote:
> 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.
From: varnk on
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.


"Cubaman" wrote:

> On Jul 27, 7:31 pm, varnk <va...(a)discussions.microsoft.com> wrote:
> > 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.
> .
>