>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