有什么区别:LoadUserProfile -vs- RegOpenCurrentUser
这两个 API 非常相似,但不清楚它们之间有什么区别以及何时应该使用它们(除了指定 LoadUserProfile 与我没有使用的 CreateProcessAsUser 一起使用。我只是模拟 hive 访问)。
加载用户配置文件 http://msdn.microsoft.com/en-us /library/bb762281(VS.85).aspx
RegOpenCurrentUser http://msdn.microsoft.com/en-us /library/ms724894(VS.85).aspx
根据服务& 注册表文章: http://msdn.microsoft.com/en-us /library/ms685145(VS.85).aspx 我们在模拟时应该使用RegOpenCurrentUser。
但是,如果用户配置文件正在漫游,RegOpenCurrentUser 应该做什么——应该加载它吗?
据我从这些文档中可以看出,这两个 API 都为线程模拟的用户提供了 HKEY_CURRENT_USER 的句柄。 因此,它们都“加载”配置单元,即将其锁定为数据库文件,并为其提供注册表 API 的句柄。
看起来 LoadUserProfile 加载用户配置文件的方式与用户登录时加载用户配置文件的方式相同,而 RegOpenCurrentUser 则不然 - 这是正确的吗? 这两个 API 如何挂载 hive 的根本区别是什么(如果有)?
发生的情况有何影响和差异(如果有)
- 如果
用户登录或注销而每个模拟句柄已在使用中,则
调用每个匹配的关闭函数(RegCloseKey 和 UnloadUserProfile)时,用户是否已经登录?
These two APIs are very similar but it is unclear what the differences are and when each should be used (Except that LoadUserProfile is specified for use with CreateProcessAsUser which I am not using. I am simply impersonating for hive accesss).
LoadUserProfile
http://msdn.microsoft.com/en-us/library/bb762281(VS.85).aspx
RegOpenCurrentUser
http://msdn.microsoft.com/en-us/library/ms724894(VS.85).aspx
According to the Services & the Registry article:
http://msdn.microsoft.com/en-us/library/ms685145(VS.85).aspx
we should use RegOpenCurrentUser when impersonating.
But what does/should RegOpenCurrentUser do if the user profile is roaming - should it load it?
As far as I can tell from these docs, both APIs provide a handle to the HKEY_CURRENT_USER for the user the thread is impersonating. Therefore, they both "load" the hive i.e. lock it as a database file and give a handle to it for registry APIs.
It might seem that LoadUserProfile loads the user profile in the same way as the User does when he/she logs on, whereas RegOpenCurrentUser does not - is this correct? What is the fundamental difference (if any) in how these two APIs mount the hive?
What are the implications and differences (if any) between what happens IF
A user logs-on or logs-off while each of these impersonated handles is already in use?
A user is already logged-on when each matching close function (RegCloseKey and UnloadUserProfile) is called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它不加载配置文件。 这样想一下:如果确实如此,那么在完成
HKEY_CURRENT_USER
句柄后,您必须以某种方式调用UnloadUserProfile()
。是的。
没有任何。
他们将获得自己打开和关闭的句柄(同一键)。
同上。
It doesn't load the profile. Think about it this way: If it did, you'd have to somehow call
UnloadUserProfile()
when finished with the handle toHKEY_CURRENT_USER
.Yes.
None.
They'll get their own handle (to the same key) that's opened and closed.
Ditto.
由于我目前正在努力完成与您相同的事情,因此我想我会补充一下我在过去几天中发现的内容。
我正在 Windows XP sp3 环境中工作,并尝试在两种不同的情况下通过 CurrentUser 注册表访问来实现模拟。
如果您遇到任何有用的内容,如果您分享您的经验,我将不胜感激。 我的堆栈溢出问题可以在这里找到
管理员> 有限用户和 有限用户> LoadUserProfile
到目前为止,我注意到的是(在 Windows XP sp3 中)
():
仅当模拟用户启用了 SeRestoreName 和 SeBackupName 权限等时才有效(仅仅为有问题的受限用户启用这两个权限是不够的,因为它仍然因访问被拒绝错误而失败 - 有关更多详细信息,请参阅我的 StackOverflow 问题)。 到目前为止,我能够成功调用
LoadUserProfile()
的唯一方法是在开始模拟之前通过管理员帐户执行此操作。RegOpenCurrentUser():
仅当用户的配置文件已加载时才能“正常”工作,到目前为止,在我所做的每一次尝试中,我只能获取 S-1-5-18 配置单元的句柄,除非用户配置单元是已在 HKEY_USERS 下加载并可访问
As I am currently trying to accomplish the same thing you are I thought I would chime in with what I've found over the last few days.
I'm working in a Windows XP sp3 environment and trying to achieve impersonation with CurrentUser registry access in two different scenarios
If you come across anything useful I would be greatly appreciative if you share your experience. My stack overflow question can be found here
Administrator > Limited User & Limited User > Administrator
What I've noticed so far is (in Windows XP sp3)
LoadUserProfile():
Only works when the impersonating user has SeRestoreName and SeBackupName privileges enabled among others (simply enabling these two for the limited user in question was not enough as it still failed with an access denied error - See my StackOverflow question for more details on that). The only way I'm able to successfully call
LoadUserProfile()
so far is to do so by an Administrator account before starting impersonation.RegOpenCurrentUser():
Only works "properly" when the user's profile is already loaded, In every attempt I've made so far I'm only able to get a handle to the S-1-5-18 hive unless the users hive is loaded and accessible under HKEY_USERS already
这两个函数在不同的情况下使用。
如果用户配置文件尚不存在,则
LoadUserProfile
适合已加载。如果用户配置文件,
RegOpenCurrentUser
是合适的已加载,即,如果您想要访问已交互登录的用户的注册表配置单元。请注意,
LoadUserProfile
通常在不进行模拟的情况下调用(因为您必须具有管理员权限才能使用它),但RegOpenCurrentUser
必须使用调用 冒充。The two functions are used in different situations.
LoadUserProfile
is suitable if the user profile is not already loaded.RegOpenCurrentUser
is suitable if the user profile is already loaded, i.e., if you want to access the registry hive for a user who is already interactively logged on.Note that
LoadUserProfile
is usually called without impersonation (because you must have admin privilege to use it) butRegOpenCurrentUser
has to be called with impersonation.