【问题标题】:File.OpenRead access using UNC path. Impersonation not working?File.OpenRead 使用 UNC 路径访问。模拟不起作用?
【发布时间】:2011-03-03 17:27:03
【问题描述】:

模拟似乎无法使用 File.OpenRead() 处理 UNC 路径是否有原因? 我正在使用CodeProject's Impersonation utility:

我有一个用户有权访问我传递给 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

【问题讨论】:

    标签: asp.net networking impersonation unc


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2010-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多