programmatically passing network credentials during file IO

A

alan.limebeer

I'm writing a quick and dirty admin tool to check 308 servers for the
Last Modified date of a specific file that exists in the same place on
all 308 servers. Using the System.IO namespace objects to access
FileInfo, I am getting a System.IO.IOException "Logon failure: unknown
user name or bad password. " I want to pass a good user/pass combo
using command-line arguments (no issues there) but I can't figure out
how to get System.IO to use the user/pass specified when accessing the
UNC's. Any ideas?

Two workarounds I'm considering:

1) have the admin use RunAs... to execute the tool

2) Map an unused drive letter using different, valid credentials,
check the file, then delete the drive mapping, rinse and repeat (Ugh,
I know)

Obviously, it'd be much nicer to specify a user/pass in my code when
calling the FileInfo methods, but I can't find anything in the .Net
docs that indicate this is possible.

Cheers,
Alan
 
Joined
Sep 22, 2008
Messages
1
Reaction score
0
Hi,
Have u got some clues. I'm having the same problem.I can't figure out how to solve it yet.
Post the answers if you've got it.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top