programmatically passing network credentials during file IO

  • Thread starter Thread starter alan.limebeer
  • Start date Start date
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
 
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
 
Back
Top