更改域用户的桌面路径 [英] Changing Desktop Path for a domain user

查看:845
本文介绍了更改域用户的桌面路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在C#中工作的一个小程序中,我更改了用户桌面的位置.我使用SHSetKnownFolderPath和SHChangeNotify做到这一点.该程序以用户身份执行.作为本地用户,一切都很好-位置已更新, 更改立即发生.但是,当我以域用户身份运行程序的这一部分时,文件夹更改永远不会发生.桌面确实会短暂闪烁,但是位置保持不变.

查看SHSetKnownFolderPath(参考Guid folderId,uint标志,IntPtr令牌,[MarshalAs(UnmanagedType.LPWStr)]字符串路径),我提供了正确的Desktop GUID(同样,它作为本地用户使用)并且标志= 0.对于"IntPtr令牌",我用过IntPtr.zero和 也尝试使用WindowsIdentity.GetCurrent().Token传递当前用户令牌,但仍然没有成功.

最后,在故障排除中,我删除了所有用户和计算机组策略,以防万一我们的安全设置阻止了某些事情.到目前为止没有任何效果.
更改域用户和本地用户的桌面路径时,我还应该考虑其他事项吗?

谢谢您的帮助
Luke

Inside a small program I'm working on in C#, I change the location of the user's desktop. I do this using SHSetKnownFolderPath and SHChangeNotify. The program executes as the user. As a local user, everything works great -- the location is updated and the change occurs immediately. However, when I run this portion of the program as a domain user, the folder change never occurs. The desktop does flicker briefly, but the location remains the same.

Looking at SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path), I provide the correct Desktop GUID is (again, this works as a local user) and flags=0. For "IntPtr token" I have used IntPtr.zero and also have attempted passing the current user token using WindowsIdentity.GetCurrent().Token, but still haven't had any success.

Finally in troubleshooting, I removed all user and computer group policies, in case our security settings were blocking something. So far nothing has worked.
Is there something else I should be taking into account when changing the desktop path for a domain user vs a local user?

Thanks for your help,
Luke

推荐答案

通过一些基本检查,我已经走了一些.我知道此时调用SHSetKnownFolderPath失败,并且与SHChangeNotify无关. SHSetKnownFolderPath返回-2147024891,我认为这暗示了权限 问题.我已经以管理员身份运行" (在Win 7中的用户上下文下),而无需进行任何更改并将UAC控件降低到最低级别.更改这些用户设置可能需要一些安全权限吗?
With some basic checking, I've gotten a little bit farther. I know at this point it is failing when calling SHSetKnownFolderPath and has nothing to do with SHChangeNotify. SHSetKnownFolderPath returns -2147024891, which I believe suggests a permissions issue. I've "Run as Administrator" (under the user context in Win 7) without any change and lowered UAC controls to their lowest level. Is there perhaps some security permission that has to be requested to change these user settings?


这篇关于更改域用户的桌面路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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