LOGON32_LOGON_INTERACTIVE = 2
LOGON32_PROVIDER_DEFAULT = 0
hToken = BinaryAlloc(8) ; allocate buffer for HANDLE
username = Environment("USERNAME")
password = AskLine("Password","Enter Windows Password:","")
dll=DirWindows(1):"advapi32.dll"
ret = DllCall(dll, LONG:"LogonUserA", LPSTR:username, LPSTR:".", LPSTR:password, LONG:LOGON32_LOGON_INTERACTIVE, LONG:LOGON32_PROVIDER_DEFAULT, LPBINARY:hToken)
password = "CLEARPASSWORD"
If ret == 1 Then
hTokenVal = BinaryPeek8(hToken, 0)
DllCall("kernel32.dll", LONG:"CloseHandle", LONG:hTokenVal)
Message("Login", "Password is VALID")
Else
err = DllCall("kernel32.dll", LONG:"GetLastError")
Message("Login", "Invalid password. Error: " : err)
EndIf
BinaryFree(hToken)
This is great Jim.
I had to fill in my Active Directory domain name where the "." is, and then it
checks against my Active Directory.
Nice stuff.
-Kirby
Glad you liked it. Yeah, there is more that can be done to verify by Group instead but I only needed this part so stopped here.
I have a situation where I wanted authentication but didn't want to have to deal with the entire system so got to wondering if I could do this. Turns out, I could :-)
Jim