views:

333

answers:

2

Is there a way to elevate privileges to the level required to write files to a network folder with our Delphi 2006 (Win32) application?

The user running the application does not have permission to write (or view) files in the network folder in question.

Any recommended techniques or alternative suggestions?

+5  A: 

You could prompt the user to enter credentials for a user with elevated permissions and then temporarily operate under that other user's login while writing to the network share. To do this, you are looking for the LogonUser and ImpersonateLoggedOnUser functions. Please see this answer.

Scott W
Thanks, that answers the question perfectly.
Mattl
+1  A: 

Use WNetAddConnection2 to connect to the UNC path, you will need to use the lpUsername and lpPassword parameters (either ask the user for them or hide them somewhere in your app).

You can choose if you want to map a local driver letter to the UNC path or not (in that case use nil for the lpLocalname parameter). After you've done that you can access the UNC path without specifying credentials.

Remko