I am trying to read files from a shared drive. The share is password protected so I am first using a net use command to access the share and then reading the files.
Here is the net use command I am using:
net use "\\server\\share\\folder name" /u:"domain\\username" "password"
This was all working fine when debugging from VS2010. Once I published to IIS 6 though, it started giving me an error: Login Failure: Unkown username or bad password.
I've read up alot about this and it seems that this issue comes mostly from the accounts not matching up. I am running my service under ASPNET account (annonymous authentication is enabled) but I can't see why this should make a difference being that I am passing a username and password through the net use command.
I am a bit lost with how this all works so if anyone can clarify, I'd really appreciate it. TIA!
few a month ago i was the similar problem. I found a library on the net that you can use for resolved your issue.
Search "PInvokeWindowsNetworking" cs file on google and now my code it's very simple to using it
string v_DirectoryName = .... //Your Network directory
PinvokeWindowsNetworking.connectToRemote(v_DirectoryName.DirectoryName, ConfigurationManager.AppSettings["TransmissionDirectoryLogin"], ConfigurationManager.AppSettings["TransmissionDirectoryPassword"]);
DirectoryInfo v_Directory = new DirectoryInfo(v_DirectoryName);
....//Manage your file and directory access
PinvokeWindowsNetworking.disconnectRemote(v_DirectoryName.DirectoryName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.