ASP.NET copy file to UNC Network Share

I’m trying to programmatically copy a file from my web server to a UNC share on a fileserver. Both machines are Win2K and on the same Domain. I am using Integrated Windows Authentication throughout my site.

My web.config file is set up as follows:

<authentication mode="Windows" />
<identity impersonate="true" />

The code is pretty straight-forward…

Dim strFileName As String = “existingfile.pdf”
Dim strSavePath As String = “\\server\share\”
File.Copy(Server.MapPath(strFileName),strSavePath) <-- ERROR HERE

The error message is as follows:
Access to the path "\\server\share\” is denied.

My user account has domain admin rights but I assume this is more likely to be an ASPNET rights problem.

Does anyone have any code snippets or suggestions that might help?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need to enable delegation on your webserver,

Follow this article to the letter,;en-us;810572

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To explain your problem a little more (I had the same issue over a year ago, I troubleshooted it for a week, THEN someone told me about that article...)

Since you are using WIA, the client and server can be properly authenticated, but since a primary-authentication token never gets created on the server, it can't pass these credentials to another computer (your fileshare computer) without delegation.

If you have more questions let me know, oh I can answer them, believe me, been there done that with security!
Mat1980Author Commented:

You sir, are a star! I followed the article in the link and everything is now working perfectly.

Many thanks!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.