Upload file via ASP.NET to Network Share Drive - USERNAME AND PASSWORD REQ

What I am trying to do is upload a file from the local computer onto a network share drive.
I am not quite sure how to add a Username/Password to my code below... I've taken the code from here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuihtmlcontrolshtmlinputfileclasstopic.asp

Can anyone help?

Thanks in advance....

HTML
--------------------------------------------------
Select File to Upload: <input id="File1" type="file" name="File1" runat="server">
                        
<p>Save as filename (no path): <input id="Text1" type="text" name="Text1" runat="server">
<p><span id="Span1" style="FONT: 8pt verdana" runat="server"></span>
<p><input id="btnUpload" type="button" value="Upload" name="btnUpload" runat="server">

VB.NET SCRIPT
----------------------------------------------------------
Private Sub btnUpload_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.ServerClick
        If Text1.Value = "" Then
            Span1.InnerHtml = "Error: you must enter a file name"
            Return
        End If

        If Not (File1.PostedFile Is Nothing) Then
            Try
                File1.PostedFile.SaveAs(("\\{server}\{Directory}\" & Text1.Value))
                Span1.InnerHtml = "File uploaded successfully to the <b>server as " & _
                                  Text1.Value & "</b> on the Web server"
            Catch exc As Exception
                Span1.InnerHtml = "Error saving file to the <b>Server as " & _
                                  Text1.Value & "</b><br>" & exc.ToString()
            End Try
        End If

    End Sub
maidstoneAsked:
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.

DBAduck - Ben MillerPrincipal ConsultantCommented:
There are a couple of ways to do this:

1) is to have the user that is in the Application Pool identity be a user that can auto pass through in authentication because the same user exists on the network machine you are connecting to.  
2) You can Create a Windows Identity principal and use the username and password and then impersonate and save. This is the more intensive one because there are ramifications that you need to make sure that you protect yourself from and this is also the slowest because it involves authentication of each request.

Does this make sense?
0
maidstoneAuthor Commented:
I dont think I quite understand either...
0
DBAduck - Ben MillerPrincipal ConsultantCommented:
They both have to do with a Windows Web Server.

So if you are wanting to put a file somewhere where the servers are connected, the only way to save a file somewhere is to have a Username/Password that has access to the place.

So in Web Server land there are 2 places.  1 is the Application Pool Identity that is set in Internet Services Manager on the web server, and the other one is to authenticate via code and use the Username and Password (to create a Windows Principal) and then save the file.

The first one is more common because the Windows Principal concept for something like this is way overkill and more complex.

Does that help?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

maidstoneAuthor Commented:
What you are saying makes no sence to me....
What I did was just put a entry into my Web.Config file....

<identity impersonate="true" userName="{Username}"
password="{Password}" />

I don't think thats the solution you were trying to get accross to me, so I went a different direction.
0
DBAduck - Ben MillerPrincipal ConsultantCommented:
Whatever the recommendation or protocol is works for me.

Ben.
0
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

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
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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.