Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Terry Parkinson
  Where is Terry Parkinson?
 Litchfield
 New Hampshire - United States
 Terry Parkinson
 Tags
Subject: User rights, Impersonation LogOn
Thread ID: 311268 Message ID: 311268 # Views: 53 # Ratings: 0
Version: Visual FoxPro 9 Category: Errors & Debugging
Date: Thursday, June 30, 2011 4:41:51 AM         
   


I'm having trouble using the LOGON32_LOGON_INTERACTIVE routine on a W7 64 bit machine. The logon is used to access files on the server. (full code below--worked for years--thanks Bernard Bout!))
The same VFP9 program runs well on a W7 32 bit machine, and 10 XP Pro machines.
The problem is that I can't print on the 64 bit machine, either to a local printer or the networked printer. All other parts of the program work on the 64 bit machine, updating files, etc.

GETPRINTER() gives me the printer list on the 64 bit machine.
lcprinter=alltrim(userstuff.printername)
SET PRINTER TO NAME (lcprinter)
works on all the other machines.

A test program I wrote to use only local files with no server logon on the 64 bit machine can use the printers. The program that logs on to the server cannot use the printers, even if I log on to the machine as administrator.
As far as I can tell, the user rights are established identically on all machines.
Is there something else I should be looking at in terms of rights?
Is there something about this logon routine that won't work fully on a 64 bit machine?

Thanks!
Terry

The printer errors I get are:
"error accessing printer spooler"
"error loading printer driver"
(again, other non-VFP programs on the 64 bit machine use the printers with no issues, as well as the VFP program I wrote to use local files only, with no impersonation.)
I've stripped the printer environment from all reports.

LogOn Code
#define LOGON32_PROVIDER_DEFAULT 0
#define LOGON32_LOGON_INTERACTIVE 2
#define LOGON32_LOGON_NETWORK 3
#define LOGON32_LOGON_BATCH 4
#define LOGON32_LOGON_SERVICE 5
#define LOGON32_LOGON_UNLOCK 7

DECLARE integer LogonUser IN AdvApi32.DLL;
string szUsername,;
string lpszDomain,;
string lpszPassword,;
integer dwLogonType,;
integer dwLogonProvider,;
integer @phToken

DECLARE integer ImpersonateLoggedOnUser IN AdvApi32.DLL integer hToken
DECLARE integer RevertToSelf IN AdvApi32.DLL

local nToken
nToken = 0

pth="\\LtServer\Ltnet\Data"
IF LogonUser("SecureAppUser","domainname","password",LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, @nToken) = 0
MESSAGEBOX("Failed to authenticate. Unable to continue",16,"XYZ Corp",0)
QUIT && RETURN
ENDIF
IF ImpersonateLoggedOnUser(nToken) = 0
MESSAGEBOX("Failed to authenticate. Unable to continue",16,"XYZ Corp.",0)
QUIT &&return
ENDIF
SET PATH TO &pth

ENTIRE THREAD

User rights, Impersonation LogOn Posted by Terry Parkinson @ 6/30/2011 4:41:51 AM