假冒的.NET(C#)及通过的Process.Start打开一个文件 [英] Impersonating in .net (C#) & opening a file via Process.start

查看:235
本文介绍了假冒的.NET(C#)及通过的Process.Start打开一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 我在做使用一些模拟的的LogonUser ,因为它是在许多地方解释。

I was doing some impersonation using the LogonUser as it was explained in numerous places.

(我用了很大的类库介绍此处,但原理似乎是相同的所有网站上)。

(I used the great class library introduced here, but the principle seems to be the same all over the web).

我已经成功地模仿,去一个地方,我的普通用户不能。但是,当我试图以编程方式打开文档文件或 TXT 文件也好,都使用的Process.Start ,我得到的错误

I've succeed to impersonate and go to a place that my "normal" user can't. But when I try to programmatically open a doc file , or txt file or whatever, using Process.Start, I get the error

没有足够的内存或磁盘   空间来运行Word。

"There is not enough memory or disk space to run Word."

我就可以开始编程的话用我的普通用户,但后来,当我尝试以编程方式使用其他用户打开特定文件,我得到:

I can start word programmatically using my normal user, but then, when I try to open the specific file programmatically using the other user, I'm getting:

拒绝访问。

顺便说一句,当我登录的手到我的电脑,这个其他用户有权限打开该文件。

BTW, when I logon by hand to my computer, this other user has the permissions to open the file.

推荐答案

这闻起来像ProcessStartInfo.LoadUserProfile一个问题。它默认为false,具有副作用的启动过程中会看到您的帐户,而不是模拟之一HKCU注册表设置。 Office程序不会喜欢这一点。

This smells like a problem with ProcessStartInfo.LoadUserProfile. It defaults to false, with the side effect that the started process will see the HKCU registry settings of your account, not the impersonated one. Office programs are not going to like this.

要注意的是AFAIK你也必须设置UseShellExecute为false,以使该设置生效。这将妨碍你通过传递一个.doc文件的文件名来启动Word的能力。你需要使用WINWORD.EXE代替。

Beware that afaik you'll also have to set UseShellExecute to false to make this setting effective. That will hamper your ability to start Word by simply passing a .doc file as the file name. You'll need to use "winword.exe" instead.

这篇关于假冒的.NET(C#)及通过的Process.Start打开一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆