LogonUser函数空密码的问题

论坛 期权论坛 脚本     
匿名技术用户   2020-12-30 15:20   30   0

LogonUser()是用来判断用户登录Windows操作系统的。但是,当密码为空的时候,LogonUser会返回FALSE。

经过研究,发现如果密码为空的时候,GetLastError会返回1327错误,也就是说,Windows不允许LogonUser以空的密码来登录。

所以,登录的代码需要更新一下:


if (LogonUser(account.strUsername, account.strDomain, account.strPassword,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUser))
{
}

应该改为

if (LogonUser(account.strUsername, account.strDomain, account.strPassword,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUser)
|| GetLastError() == 1327)
{
}



这样,LogonUser应该就没问题了。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP