Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Implement NT user security on VFP exe
Message
 
À
09/08/2006 10:45:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Installation et configuration
Divers
Thread ID:
01144151
Message ID:
01144165
Vues:
17
Hi,

> that EXE would have the embedded authentication to provide the read/write ability to the required directory data files. Ideally the user would still not have the ability to do anything to these files through the XP explorer as only the EXE itself would have permissions.

If you only deploy on Windows XP or later, that's possible using an API function that performs a programmatic logon. On Windows 2000 and NT this function is only available to Administrators. Here's the code:
* based on an idea by Alf Borrmann
CLEAR 

LOCAL lnOK, lnHandle
DECLARE Long LogonUser IN WIN32API ;
	String, String, String, Long, Long, Long@
DECLARE LONG GetLastError IN WIN32API

lnHandle = 0	
* SeNetworkLogonRight
* SeTcbPrivilege (Windows 2000 and prior)
lnOK = LogOnUser( "username", "domain", "password", 3, 0, @lnHandle )
IF m.lnOK == 0
	? "Error in LogOnUser ", GetLastError()
	RETURN
ENDIF

DECLARE Long ImpersonateLoggedOnUser IN WIN32API Long
DECLARE Long RevertToSelf IN WIN32API

? SYS(0)
lnOK = ImpersonateLoggedOnUser( lnHandle )
IF m.lnOK == 0
	? "Impersonation failed"
ELSE
	? SYS(0)
	RevertToSelf()
	? SYS(0)
ENDIF 

DECLARE Long CloseHandle IN WIN32API Long 
CloseHandle(lnHandle)
--
Christof
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform