提取已登录用户

时间:2017-10-25 13:55:54

标签: c# windows internet-explorer service desktop-application

目标实现:提取已登录用户的IE浏览历史记录。 IE 11.

解决方案:我关注<“http://theagussantoso.blogspot.com/2008/11/get-temporary-internet-explorer-files.html”>?预期解决方案的链接。这在我的 Dev环境(在VS 2017中)都运行良好。我从“C:\ Users [用户名] \ AppData \ Local \ Microsoft \ Windows \ INetCache”获取所有浏览器历史记录。

问题: 该解决方案必须在Windows上作为“服务”运行。当应用程序在系统上作为服务运行时,它在“NT AUTHORITY \ SYSTEM”下运行(通过“WindowsIdentity.GetCurrent(。。Name”)找到它,因此,程序流程无法找到“C:\ Users” [用户名] \ AppData \ Local \ Microsoft \ Windows \ INetCache“读取IE历史记录的位置 我尝试过按照某些链接建议的解决方案,但没有一个对我有用:
试验1:

        IntPtr accessToken = IntPtr.Zero;
        WindowsIdentity identity =  new WindowsIdentity(accessToken); 
        LOG.Debug("Identity Name: " + identity.Name);
        WindowsImpersonationContext context = identity.Impersonate();

获取错误:令牌不能为零

试验2:我只是试图冒充我的Dev中的用户,但它没有产生任何结果而没有抛出任何错误:

WindowsIdentity identity = WindowsIdentity.GetCurrent(); 
        LOG.Debug("Identity Name: " + identity.Name);
        WindowsImpersonationContext context = identity.Impersonate();

        //... my code here
        context.Undo();



我不知道如何强制我的代码在当前登录用户下运行,以便运行缓存代码以从“C:\ Users [User Name] \ AppData \ Local \ Microsoft \ Windows \ INetCache”获取数据。任何帮助或建议表示赞赏。

感谢。

0 个答案:

没有答案
相关问题