在Windows中获取登录用户的用户名/密码

编程入门 行业动态 更新时间:2024-10-24 14:25:08
本文介绍了在Windows中获取登录用户的用户名/密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Windows中是否有任何API可以获取当前登录的用户名和密码?

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中获取登录用户的用户名/密码

本文发布于:2023-11-06 06:59:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563004.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户名   密码   用户   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!