programmatically passing network credentials during file IO

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alan.limebeer@gmail.com

    #1

    programmatically passing network credentials during file IO

    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.IOExc eption "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

Working...