开发者

Create a file switching user in the same process

I have a program that needs to create a file in a directory where the user who is running the application doesn't has permission to write, but other user has. Is possible to do that?

I know that I can login a user with write privileges in that folder with LogonUserA, but then I don't know how to create a file using the returned token. Also, I know the user na开发者_如何学编程me and password of the user who can write in that directory.

I use Delphi, but the example or ideas could be in any language.


HANDLE hToken = LogonUser(...);
ImpersonateLoggedOnUser(hToken);
// do something
RevertToSelf();
CloseHandle(hToken);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜