开发者

Impersonating in .net (C#) & opening a file via Process.start

开发者 https://www.devze.com 2023-01-30 08:25 出处:网络
HI, I was doing some impersonation using the LogonUser as it was explained in numerous places. (I used the great class library i开发者_如何学运维ntroduced here, but the principle seems to be the same

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

(I used the great class library i开发者_如何学运维ntroduced here, but the principle seems to be the same all over the web).

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

"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:

"access denied".

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


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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消