Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Username and Password from Windows

Status
Not open for further replies.

peterpruimboom

Programmer
Apr 28, 2002
20
NL
Hello,

When a user must login into my programm I woul'd like to use the Windows username an password of the currently logged in user. I know that the username can be found by using the GetUserName function but I don't have a clue how to check the password. I understand that the password on itself is not retrievable but there must be a way to do this. This because I've seen it work with an application.

Can anyone help me with this?

Thanks, Peter.
 
In your dreams, pal. Can you see the spyware comming out sending userID and password back to the authors? Passwords are evaluated with a one-way algorithm: if X is the password then f(X) is calculated and compared to an f(X) stored in the SAM file. Knowing f(X) does not allow you to recalculate X. Why would you need the password anyway? ;-)
 
I'm not interested in the password but want to check of a given password equals the windows logon password. The UserID I can get (in normal format) with the GetUserName function in the windows API.
 
forgot where I got this but it worked on my Win98 box.
does not work on my WinXP box though.

Code:
Private Declare Function WNetVerifyPassword Lib "mpr.dll" Alias _
    "WNetVerifyPasswordA" (ByVal lpszPassword As String, _
    ByRef pfMatch As Long) As Long

Private Function VerifyWindowsLoginUserPassword _
        (ByVal Password As String) As Boolean
    Dim rtn As Long, Match As Long
    rtn = WNetVerifyPassword(Password, Match)
    If rtn Then
        VerifyWindowsLoginUserPassword = False
    Else
        VerifyWindowsLoginUserPassword = (Match <> 0)
    End If
    Debug.Print rtn, Match
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top