We have a .NET windows application that allows users to upload files to a shared folder on our network and also to view those files. The files are uploaded with FileInfo.CopyTo() and the files are viewed with Process.Start(fileName). This has been working well because all of the users of the application have been logged into the domain where the share is.
The app has recently been made available to users outside of our office. They will be coming in through a VPN (SonicWall) so we have created users for them in our domain, but after connecting through the VPN, they are not actually authenticated in the domain. If they try to access the files through the application at this point, there will be an exception because the share is not yet visible to them.
I have successfully used Uwe Keim's Impersonator class (
http://www.codeproject.com/KB/cs/zetaimpersonator.aspx) to view the files. This class calls LogonUser() so that my call to Process.Start(fileName) is executed as a user that has permission to access the share. I can't use this technique for uploading the files, though, because the copy operation will need access to both the client's machine and the share.
If I have the users first browse to the share, they will be prompted by windows to supply their credentails and all is well with accessing the files through the app. Is there a way in code to mimic what happens when the user browses to the share and supplies credentials?
Our community of experts have been thoroughly vetted for their expertise and industry experience.