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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using LogonUser of ADVAPI32.dll

Status
Not open for further replies.

jasontektips

Programmer
May 30, 2003
23
0
0
SG
Hi,

I'm trying out the LogonUser function of ADVAPI32.dll with a simple VB program, but it always return me FALSE. The following is the code:
____________________________________________________
Option Explicit

Private Declare Function LogonUser Lib "Advapi32.dll" 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 Long

Private Sub cmdTestPassword_Click()
Dim phToken As Long
If LogonUser("jasonID", _
"jasonDomain", _
"jasonPassword", _
3, _
0, _
phToken) = 0 Then

MsgBox ("Wrong Password!!!")
Else
MsgBox ("Correct Password!!!")
End If

End Sub
____________________________________________________

I've tried to create the ID:jasonID with the appropriate password in both local machine as well as the Domain Controller, but all return me FALSE.

Can someone help to rectify this.
Many Thanks


Jason
 
Hi,

Just to share ...

I've found out that I'll need to do the following setting in my Win2000 Pro before I can use ADVAPI32.dll :

Action:
1) Go to Control Panel -> Administrative Tools -> Local security Policy
2) Go to Local Policies -> User Right Assignments
3) Doubleclick on 'Act as part of the operating system', and add Everyone to it.
4) Reboot your PC

However, I do not know the rational for such settings to have the functions of ADVAPI32.dll to be activated, and I presume its tru if I'm to use other APIs.

regards,
Jason
 
I give a reasonably thorough example of LogonUser in thread222-548282
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top