1

Is there a reason Impersonation does not seem to work with a UNC path using File.OpenRead()? I'm utilizing CodeProject's Impersonation utility:

I have a user with rights to the share that I'm passing to OpenRead().

This is my code and it's not accessing the file:

try
{
    bool canImp = imp.ImpersonateValidUser(impUser, domain, impPwd);

    FileStream fs = File.OpenRead(filePath);
    logger.Debug("File stream opened...");
    byte[] b = new byte[fs.Length];
    fs.Read(b, 0, b.Length);
    fs.Close();

    // code continued
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
ghost_mv
  • 1,170
  • 4
  • 20
  • 43

1 Answers1

1

Turns out I was using the IP address in my impersonation for the domain, rather than the friendly domain name. Once I used the friendly domain name, the impersonation worked.

ghost_mv
  • 1,170
  • 4
  • 20
  • 43