acdagirl
asked on
programmatic impersonation for file.Move
I have some old impersonation code that is supposed to let me access a remote fileshare. I'm trying to add a file.Move within the code somewhere but it keeps failing without giving me real details on the error. The fileshare is maintained by another IT department and so I can't modify users/security on that box myself, hence the programmatic part. does anyone know a good article or tutorial on how to move files from a local box to a remote one using impersonation? I'm using asp.net as this is a web app.
The code works on Windows Forms (I tested)
I guess with a little handling -or- not, will fit in asp.net
I guess with a little handling -or- not, will fit in asp.net
ASKER
where is the file.move section? I already have the code you provided as explained above. I need the file moving code in there somewhere.
ASKER
anyone?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks - it's what I wanted to check, however it seems that because i'm trying to move a file from a file control (not the standard .net file upload) I have additional complications with security - the control I'm using appears to buffer the file in a temp directory which then requires different authentication. I think I'm just going to have to copy the file locally/temporarily on the web server then move it to the file share using the impersonation code above.
thanks!
thanks!
On the web server side the folder you want to move your file to must have IUSR rights to read/write/modify.
You should check with your ISP to allow this in the folder -or- if you run your web server check the folder
I am developing .asp pages, and I have not much of expirience in .aspx, but definately you must have IUSR rights to any folder to modify its contents
Have fun coding...
You should check with your ISP to allow this in the folder -or- if you run your web server check the folder
I am developing .asp pages, and I have not much of expirience in .aspx, but definately you must have IUSR rights to any folder to modify its contents
Have fun coding...
ASKER
thanks!
Dim myDomainName As String = "", thisUserName As String = "", thisPassword As String = ""
Dim imp As New RunAs_Impersonator
Try
imp.ImpersonateStart(myDom
'//Add code to run as UserName here
'everything between ImpersonateStart and ImpersonateStop will be run as the impersonated user
imp.ImpersonateStop()
Catch ex As Exception 'make sure impersonation is stopped whether code succeeds or not
MsgBox(ex.Message)
imp.ImpersonateStop()
End Try
Open in new window