简体   繁体   English

如何通过C#代码将用户帐户值设置为“不得输入用户名和密码才能使用此计算机”

[英]How to set to user account value “must not enter a user and password to use this computer” through c# code

如何设置用户帐户值“必须不输入用户名和密码才能使用此计算机”,在启动计算机时,用户不必通过c#代码插入用户名和密码

There are two ways of doing this, and both ways are fairly insecure. 有两种方法可以做到,而且两种方法都不安全。

One way to do it would be to clear out the password for the user, in which case, if it is the only user account on the system in Windows XP or higher, it will automatically log itself in. 一种方法是清除用户密码,在这种情况下,如果它是Windows XP或更高版本中系统上的唯一用户帐户,它将自动登录。

The other way to do it, is to create three registry entries under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon : 另一种方法是在HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Windows NT \\ CurrentVersion \\ Winlogon下创建三个注册表项:

DefaultUserName (reg_sz): Set to the user's username
DefaultPassword (reg_sz): Set to the user's password
AutoAdminLogon (dword): Set to 1 to enable; 0 to disable

More information is available here: http://support.microsoft.com/kb/315231 可在此处获得更多信息: http : //support.microsoft.com/kb/315231

Please be aware that this information is visible in the registry to anyone who has the ability to run the registry editor, so make sure the password is not something used elsewhere, or that the workstation is secure from other users. 请注意,任何有能力运行注册表编辑器的人都可以在注册表中看到此信息,因此请确保密码未在其他地方使用,或确保工作站不受其他用户的影响。

To set this value through code, you can do the following: 要通过代码设置此值,可以执行以下操作:

        RegistryKey winlogonKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("WinLogon", true);
        winlogonKey.SetValue("DefaultUserName", "the_user's_username");
        winlogonKey.SetValue("DefaultPassword", "the_user's_password");
        winlogonKey.SetValue("AutoAdminLogon", 1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过c#代码将密码更改为用户帐户? - how to change password to user account, by c# code? C#如何使用WMI在远程计算机中创建用户帐户 - C# how can i use WMI to create user account in a remote computer 通过C#代码创建SFTP或FTP用户帐户 - Creating SFTP or FTP user account through c# code 来自C#中IP地址的计算机用户帐户名称 - user account name of computer from ip address in C# 如何使用 MSAL C#、.net 核心在 Azure AD B2C 用户帐户上重置密码? - How to reset password on Azure AD B2C user account using MSAL C#, .net core? 使用C#检测用户是否必须在Active Directory中重置密码 - Detect if User Must Reset Password In Active Directory Using C# 通过C#MVC3中的成员身份创建新用户时,如何使用生成的密码或临时密码? - How do I use a generated or temporary password when creating a new user through membership in C# MVC3? 如何查找哪个用户最后通过C#中的Active Directory登录到给定的计算机? - How to find what user last logged onto a given computer through Active Directory in C#? 如果用户帐户处于活动状态,如何签入C# - How to check in C# if user account is active 如何使用普通用户帐户运行C#应用程序EXE? 打开UAC时,我不想提供管理员用户名和密码 - How to run C# application EXE with normal user account? I don't want to provide Admin user name and password when UAC is on
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM