我如何可以启动Internet Explorer进程作为另一个用户,一拉/ netonly?(How

2019-06-27 06:04发布

我试图启动Internet Explorer从我们的WPF应用程序的其他用户,这样,当我们的用户访问(内部)的网站,他们默默地通过集成Windows身份验证进行身份验证。

我们不希望,当你启动一个进程,首次在计算机上推出的iexplore.exe作为发生,因为怪异的部署/环境问题的其他用户,并尝试建立IE7 / 8的第一次。 不过,如果你有如何忽略每台机器上的每个IE安装的解决方案,我很乐意听到这种说法。

回到我的预期问题。 我能够用得到确切的IE冒充行为,我想*从命令提示符runas (感谢https://serverfault.com/questions/70376/runas-domain-account-still-asks-for-password ):

c:\> runas /noprofile /netonly /user:MyDomain\MyUser iexplore.exe

*注:我不能使用runas为我们的WPF应用程序的原因有很多,但最终结果是我想要的。

无论如何,我想在C#等效代码,做了runas /noprofile /netonly iexplore.exe

我中途那里的P / Invoke上CreateProcessWithLogonW 。 这是我有:

uint LOGON_NETCREDENTIALS_ONLY = 2;
var lpStartupInfo = new CreateProcessWithLogonW_PInvoke.STARTUPINFO();
CreateProcessWithLogonW_PInvoke.PROCESS_INFORMATION processInformation;

CreateProcessWithLogonW_PInvoke.CreateProcessWithLogonW(
                userName,
                domain,
                pw,
                LOGON_NETCREDENTIALS_ONLY,
                null,
                commandLine,
                0,
                null,
                null,
                ref lpStartupInfo,
                out processInformation);

这成功地启动IE浏览器,但似乎并没有在所有模拟用户。 我能够通过冒充runas命令的用户,所以我98%肯定的验证失败不是IE /区/密码/ IIS设置,这只是一些我不这样做就在我的呼吁CreateProcessWithLogonW()

有一两件事我注意到的是, runas /netonly如果我添加的命令只能/noprofile开关,这恐怕是被绊倒了我。 我不知道如何设置通过P / Invoke的这种开关在C#中的等价物。

帮助理解与任一溶液(解决“IE运行向导时我启动它的第一次”,或寻找怪物P /调用设定我缺少)。

Answer 1:

好吧,我是非常非常接近。 神奇的修复程序添加-noframemerging到IEXPLORE.EXE调用,这......说实话我不知道它做什么,它使用的短语“进程框架”,这是真棒,或许意味着东西给你。

在任何情况下,这似乎得到解决。

var arguments = "-noframemerging " + url;
var pathToIExploreExe = GetFullPathToIExploreExe();
var commandLine = string.Format("\"{0}\" {1}", pathToIExploreExe, arguments);

uint LOGON_NETCREDENTIALS_ONLY = 2;
var lpStartupInfo = new CreateProcessWithLogonW_PInvoke.STARTUPINFO();
CreateProcessWithLogonW_PInvoke.PROCESS_INFORMATION processInformation;

CreateProcessWithLogonW_PInvoke.CreateProcessWithLogonW(
            userName,
            domain,
            pw,
            LOGON_NETCREDENTIALS_ONLY,
            null,
            commandLine,
            0,
            null,
            null,
            ref lpStartupInfo,
            out processInformation);


Answer 2:

CreateProcessWithLogonW要求指定的用户帐户必须被允许以交互方式登录。 难道是一个问题吗? 尝试CreateProcessAsUser功能是否正常工作。



文章来源: How can I launch an Internet Explorer process as another user, a la /netonly?