Reputation: 133
I am trying to connect to a network location through my ASP.NET web application using WNetAddConnection2. Every thing works perfectly when I debug it using the ASP.NET Development Server provided along with VS2010. But when I deploy the code in a Windows Server 2008 R2 it does not place the file and throws a Win32 exception with error code 0X80004005. The application pool identity is network service and i am using a domain user account for imparsanation.
I have checked the connectivity and user name password validity using the command and it works pefectly from the server runas /netonly /user:DOMAIN\User "explorer.exe \Path"
Please also note my firewall is switched off and i dont have an antivirus running on the Windows Server 2008.
Any help is really appreciated.
I have used the sample code from How to provide user name and password when connecting to a network share
Upvotes: 1
Views: 2271
Reputation: 133
The WNetUseConnection will work, we need to define all its structures properly. WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null);
Upvotes: 1
Reputation: 70369
Starting with Windows Vista Windows Service behave security-wise differently and are not allowed any "desktop-related activity" (like mounting someting)...
ASP.NET runs under IIS which runs as a Service - what you try is not supported and can only be achieved by circumventing several issues with permissions etc.
Not sure what you are trying to achieve ?
Perhaps there is a different way to achieve that goal...
Upvotes: 1