Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't get GetLastError() to return a value?!
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01101255
Message ID:
01101347
Views:
10
Are you able to do this from the Command Window?
DECLARE integer GetLastError IN kernel32
DECLARE integer CloseHandle IN kernel32 integer hObject
DECLARE integer LogonUser IN advapi32 string lpzUser, string lpzDomain, string lpzPass, integer dwLogonType, integer dwLogonProvider, integer @phToken
nToken = 0
cUser = inputbox("User:")
cPass = inputbox("Password:") && enter an invalid password
cDomain = inputbox("Domain:")

= LogonUser(cUser,cDomain,cPass,3,0,@nToken)
? "Error:",GetLastError()
I do this and still get a 0.

Are you authenticating a local user or a domain user? I'm working with a domain user.

Thanks for your help!

>Rod,
>
>Try to call GetLastError right after the LogonUser fails:
>
>nLastError = GetLastError()
>
>In your code the GetLastError is called concurrently with the TRANSFORM() and the MESSAGEBOX() calls. May happen that any of these already reset the last error state.
>
>This code works for me:
>
>nToken = 0
>= LogonUser(cUsr, cDomain, cPwd,;
>	LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, @nToken)
>
>IF nToken = 0
>* 1326 = ERROR_LOGON_FAILURE
>* 1327 = ERROR_NO_SUCH_MEMBER
>* 1385 = ERROR_LOGON_TYPE_NOT_GRANTED
>	? "Error:", GetLastError()
>	RETURN .F.
>ENDIF
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform