CheckWindowsUser – Validate a username/password pair

CheckWindowsUser – Validate a username/password pair

Private Declare Function LogonUser Lib "Advapi32" Alias "LogonUserA" (ByVal _    lpszUserName As String, ByVal lpszDomain As String, _    ByVal lpszPassword As String, ByVal dwLogonType As Long, _    ByVal dwLogonProvider As Long, phToken As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _    LongConst LOGON32_PROVIDER_DEFAULT = 0&Const LOGON32_LOGON_NETWORK = 3&' Check whether a username/password pair is correct'' if DOMAIN is omitted, it uses the local account database' and then asks trusted domains to search their account databases' until it finds the account or the search is exhausted' use DOMAIN="." to search only the local account database''  IMPORTANT: works only under Windows NT and 2000Private Function CheckWindowsUser(ByVal UserName As String, _    ByVal Password As String, Optional ByVal Domain As String) As Boolean    Dim hToken As Long, ret As Long    ' provide a default for the Domain name    If Len(Domain) = 0 Then Domain = vbNullString    ' check the username/password pair    ' using LOGON32_LOGON_NETWORK delivers the best performance    ret = LogonUser(UserName, Domain, Password, LOGON32_LOGON_NETWORK, _        LOGON32_PROVIDER_DEFAULT, hToken)        ' a non-zero value means success    If ret Then        CheckWindowsUser = True        CloseHandle hToken    End IfEnd Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several