paulfenwick
Technical User
Hi, Is it possible to use the logonuser call in advapi32.dll just to check that a username and password are valid.
I want to allow access to a database on a shared PC by simply 'asking' windows if the username and password are correct. I dont want to do any impersonation or anything just recieve back an answer yes / no.
Searching though the forums it seems that logonuser should be possible but I cant get it to work.
I tried putting:
Declare Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Boolean
in a public module, then just doing a simple call like:
Private Sub Command4_Click()
Dim UserName, Domain, Pwd As String
Domain = "domain"
UserName = Text1.Text
Pwd = Text2.Text
If LogonUser(UserName, Domain, Pwd) = False Then
MsgBox ("wrong password")
End If
End Sub
to test it out but it didnt work.
Thanks for any help
I want to allow access to a database on a shared PC by simply 'asking' windows if the username and password are correct. I dont want to do any impersonation or anything just recieve back an answer yes / no.
Searching though the forums it seems that logonuser should be possible but I cant get it to work.
I tried putting:
Declare Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Boolean
in a public module, then just doing a simple call like:
Private Sub Command4_Click()
Dim UserName, Domain, Pwd As String
Domain = "domain"
UserName = Text1.Text
Pwd = Text2.Text
If LogonUser(UserName, Domain, Pwd) = False Then
MsgBox ("wrong password")
End If
End Sub
to test it out but it didnt work.
Thanks for any help