Getting user name/password of the logged in user in Windows(在 Windows 中获取登录用户的用户名/密码)
问题描述
是否有任何 API 可以在 Windows 中获取当前登录的用户名和密码?
Is there any API to get the currently logged in user's name and password in Windows?
提前谢谢你.
推荐答案
密码:不,出于安全原因,它不会被保留 - 它被使用,然后被丢弃.您可以从注册表中检索该用户的加密密码,给予足够的权限,然后使用类似 彩虹表之类的东西对其进行解密,但使用当前方法非常耗费资源和时间.更好地提示用户.
Password: No, this is not retained for security reasons - it's used, then discarded. You could retrieve the encrypted password for this user from the registry, given sufficient privileges, then decrypt it using something like rainbow tables, but that's extremely resource intensive and time consuming using current methods. Much better to prompt the user.
或者,如果您想像 Novell 那样实现某种单点登录"系统,您应该通过 GINA(Vista 之前)或凭据提供程序 (Vista) 来实现,这将导致您的代码给定登录时的用户名和密码,密码唯一可用的时间.
Alternatively, if you want to implement some sort of 'single signon' system as Novell does, you should do it via either a GINA (pre-Vista) or a Credential Provider (Vista), which will result in your code being given the username and password at login, the only time at which the password is available.
对于用户名,获取 当前 用户名(运行您的代码的人)很容易:AdvApi32.dll 中的 GetUserName 函数正是为您完成了这项工作.
For username, getting the current username (the one who is running your code) is easy: the GetUserName function in AdvApi32.dll does exactly this for you.
如果你作为服务运行,你需要记住没有一个登录用户":任何时候都有几个,例如LocalSystem,NetworkService,SYSTEM等帐户,除了任何实际的人.本文提供了一些示例代码和文档.
If you're running as a service, you need to remember there is no one "logged in user": there are several at any time, such as LocalSystem, NetworkService, SYSTEM and other accounts, in addition to any actual people. This article provides some sample code and documentation for doing that.
这篇关于在 Windows 中获取登录用户的用户名/密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Windows 中获取登录用户的用户名/密码


基础教程推荐
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 这个宏可以转换成函数吗? 2022-01-01