wik*_*iki 28 windows command-line-interface authentication credentials
在 Windows 平台上,是否有任何命令行实用程序可以传递username,password domain name以验证凭据(或可能给出帐户被禁用、不存在或过期的错误)?
Eva*_*son 20
您可以使用该net use命令,在命令行上指定用户名和密码(在表单中net use \\unc\path /user:username password并检查errorlevel返回以验证凭据是否有效。
该runas命令也可以工作,只是您将有更艰难的时间来测试输出。
测试帐户是否存在的凭据将是使用net user或 的问题dsquery。该net user命令不会告诉您帐户是否被锁定,但查询lockoutTime用户帐户的属性可以告诉您。
小智 16
在 Powershell 中:
Function Test-ADAuthentication {
param($username,$password)
(new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null
}
PS C:\> Test-ADAuthentication "dom\myusername" "mypassword"
True
PS C:\>
Run Code Online (Sandbox Code Playgroud)
参考:https : //stackoverflow.com/questions/7663219/how-to-authenticate-an-user-in-activedirectory-with-powershell
| 归档时间: |
|
| 查看次数: |
121033 次 |
| 最近记录: |