1

模拟似乎不适用于使用 File.OpenRead() 的 UNC 路径是否有原因?我正在使用CodeProject 的 Impersonation 实用程序

我有一个用户有权访问我传递给 OpenRead() 的共享。

这是我的代码,它没有访问文件:

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
4

1 回答 1

1

原来我在模拟域时使用了 IP 地址,而不是友好的域名。一旦我使用了友好的域名,模拟就奏效了。

于 2011-03-11T19:54:51.567 回答