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:
01101289
Views:
10
Is there any way then to find out WHY the login failed? In other words, the username could've been bad, the password could've been bad the administrator could've locked the user out, the user may have to change their password first, etc. Is there any way to get that information using LogonUser?

>>I'm trying to use GetLastError API call to figure out why a call to LogonUser may have failed. However, no matter what I do, GetLastError always returns 0. LogonUser will return 1 when I enter a valid username/password. If I enter the same username with a bogus password, LogonUser returns a 0 indicating there was a problem but GetLastError() still returns a 0.
>>
>>I've included my code below. Does anyone know what I might be doing wrong?
>>
>>
>>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
>>
>>IF LogonUser("user_name","domain.com",INPUTBOX("Password:"),3,0,@nToken) = 0
>>   = MESSAGEBOX("Error: " + TRANSFORM(GetLastError(),"99999999"))
>>ELSE
>>   = CloseHandle(nToken)
>>ENDIF
>>
>>RELEASE ALL
>>
>>
>>Thanks for your input!
>
>Rodd,
>
>GetLastError would not help you here, I believe. It is used to determine failure in the function, but I don't think it could be used in this context.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform