Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to access win32api function LogonUser
Message
From
28/12/1998 11:18:15
 
 
To
28/12/1998 10:31:13
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00170686
Message ID:
00170791
Views:
95
>Here's why GetLastError code returns 127 (Procedure not found):
>
>When you declare a dll function in Win32API, VFP looks for it in several dlls. If the function is not in the first dll it searches, the global lasterrorcode is set to 127 and the next dll is searched and so on. But the lasterrorcode remains 127. This is why GetLastError should be declared before using any other Win32 API function. Otherwise, the global error code is overwritten, so, lost. Warning: The last error code may be 127 even if you specify the correct dll (or the function is in the 1st searched dll) if the function has ANSI and UNICODE versions and VFP must choose the correct one.
>
>In this particular case, I would say that GetLastError code will return ERROR_PRIVILEGE_NOT_HELD, because the calling process must have the SE_TCB_NAME privilege.
>
>Although the help says that LogonUser enables this privilege when needed, from my experience I've seen that this is not true. :(
>

And why it works on my NT System when I test it at home; I'm using an Admin account (both domain and local) and logging into another domain admin account for my test.

Thanks,

Ed

>Vlad
>
>>DECLARE INTEGER LogonUser IN WIN32API;
>> STRING lpszUserName, ;
>> STRING lpszDomain, ;
>> STRING lpszPassword, ;
>> INTEGER dwLogonType, ;
>> INTEGER dwLogonProvider, ;
>> INTEGER @ phToken
>>
>>cUser = 'user1'
>>cDomain = 'MyDomain'
>>cPasswd = 'xyzzy'
>>nLogonType = 2 && LOGON32_LOGON_INTERACTIVE (see WINBASE.H)
>>nProvider = 0 && LOGON32_PROVIDER_DEFAULT (see WINBASE.H)
>>nToken = 0
>>nResult = LogonUser(cUser, cDomain, cPasswd, nLogonType, nProvider, @nToken)
>>
>>Don't forget to CloseHandle() the phToken - the memory used by the object
>>remains active until the handle is closed explicitly by the owner, even
>>if the variable holding the value goes out of scope.
>>
>>
>>>handle = 0
>>>h_user = "user1"
>>>h_serv = "domain"
>>>h_a1 = 1
>>>h_a2 = 0
>>>h_pass = "passw1"
>>>a= LogonUser(@h_user,@h_serv,@h_pass,@h_a1,@h_a2,@Handle)
>>>? a && returns 0
>>>
>>>DECLARE INTEGER GetLastError IN WIN32API
>>>lnError = GetLastError()
>>>wait window STR(lnError) && Returns 127
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform