CheckWindowsUser – Check whether a username/password pair is correct

 Shared Function _    LogonUser(ByVal userName As String, ByVal domain As String, _    ByVal password As String, ByVal dwLogonType As Integer, _    ByVal dwLogonProvider As Integer, ByRef phToken As Integer) As IntegerEnd Function Shared Function _    CloseHandle(ByVal hObject As Integer) As IntegerEnd Function' 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 2000Function CheckWindowsUser(ByVal userName As String, ByVal password As String, _    Optional ByVal domain As String = "") As Boolean    Const LOGON32_PROVIDER_DEFAULT = 0&    Const LOGON32_LOGON_NETWORK = 3&    Dim hToken, ret As Integer    ' provide a default for the Domain name    'If domain.Length = 0 Then domain = Nothing    ' 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:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS