Can I set a specific user as FileSystemObject's authentication identity?

prairie1 used Ask the Experts™
Hi all,
In Access 2007 or 2003, I'm using the FSO for moving files.  I need the FSO to have permissions which the logged on user does not have.  

In this case, the machine is a server and there is no human user, Access is running as a Scheduled Task under a less privileged user account.  This is all fine but now I need to pluck and place files into area's where I don't want this user account to have explicit permissions.

I'm kludging it right now by placing a NET USE statement in the code with a higher privileged user's credentials, just prior to Setting the FSO.  With the Use statement in place, the fso all of a sudden can access these files (I'm not mapping a drive, just running the NET USE which appears to cache credentials for the entire console session).

So what I'd like to do is have that be a little more narrowly focused, ie permissions given directly to the fso object.

Is this possible, or does anyone have an other suggestions on how to accomplish this?
(I've added this to the .Net area because this app is a prototype and will eventually be done in .Net)
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Consultant
Top Expert 2010
So far as I know you can't assign credentials to the FSO.
You are correct about NET USE caching the credentials for all future interaction with the specified remote server, and that is probably a decent way to go.
Ideally, file permissions should be set so that users (or in this case the application) have the access they need.
Alternatively, you can run the whole process as another user by adjusting the settings in the task scheduler, or achieve basically the same thing by using the LogonUser() and ImpersonateLoggedOnUser() API's.


Thanks, that will save me from trying to dig deeper into the fso.  I'll stick with the Net Use for now...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial