I want to set up a Virtual Path Provider pointing to a a folder on another machine so i put this in my Web.Config:
<add showInFileManager="false" virtualName="Z" virtualPath="~/Z/" bypassAccessCheck="true" physicalPath="\\2126.96.36.199\MyShare" name="Zcolon" type="EPiServer.Web.Hosting.VirtualPathNativeProvider,EPiServer" />
This works fine when I run the site locally or on my development server and the VPP is set up pointing to some test share. However, in the live environment the VPP is pointing to a share that requires authentication, something like <domain on remote machine>\username + password.
When remote-desktopping to the live environment I can connect to the remote machine by just running \\2188.8.131.52\MyShare and manually type in the authentication credentials as I am prompted so I am sure that the connection between the web server and the customers file server is up and running.
My question is of course, how would I go about this programmatically? I have done some shallow research into coding something like VirtualPathNativeImpersonatedProvier : VirtualPathNativeProvier and implementing impersonation like this but I haven't gotten around to testing it much yet since it completely kills the site when it's not working:
<add showInFileManager="false" virtualName="Z" virtualPath="~/Z/" bypassAccessCheck="true" physicalPath="\\2184.108.40.206\MyShare" name="Zcolon" domain="RemoteMachineDomain" username="RemoteUser" password="zeEagleHasLanded" type="MyNamespace.VirtualPathNativeImpersonatedProvider,MyAssembly" />
Even if I got it working, would I just set up auth. credentials and then start impersonating in the VPP constructor?
Is there some "more cleverer" way of doing this?
Couldn't you change the application identify to a user that is authenticated on the share? IE user exists both on the file share machine and web server.