0

我试图在我的 C# 代码中模拟用户以在 Windows 资源管理器中打开文件共享。但它不工作!我的代码如下。

Impersonator i = new Impersonator();

using (new Impersonator("userA", "domainA", "pa$$word", LogonType.LOGON32_LOGON_INTERACTIVE, LogonProvider.LOGON32_PROVIDER_DEFAULT))
{
    Process.Start(@"c:\windows\explorer.exe", @"\\fileshare\abc");
    Response.Write("Impersonated User: " + WindowsIdentity.GetCurrent().Name + "<br />"); 
    Response.Write("Logon User: " + Request.ServerVariables["LOGON_USER"] + "<br />"); 
    Response.Write("Authenticated User: " + Request.ServerVariables["AUTH_USER"] + "<br />") 
}

我正在使用代码从该站点进行模拟:

http://platinumdogs.wordpress.com/2008/10/30/net-c-impersonation-with-network-credentials/

我想这是因为登录和身份验证是我的 Windows 登录,因为我使用的是 Windows 身份验证?

我模拟的帐户是域帐户,并且拥有文件共享的完整帐户。

请帮忙

额外的:

我也尝试使用此代码,但它没有用。我收到“拒绝访问”错误

string target = "'_blank'";
string script = "window.open(" + @"'file://fileshare/abc'" + "," + target + "," + "'status=no, menubar=yes, toolbar=yes');";
Page.ClientScript.RegisterStartupScript(this.GetType(), "someUniqueId", script, true);
4

1 回答 1

1

You can't start Explorer from an asp.net worker process. Explorer is a GUI application that requires a WindowStation to display.

When you say "it doesn't work", do you mean explorer doesn't open up when you go to the web page?

于 2012-04-06T18:49:52.237 回答