Search  
Thursday, May 24, 2012 ..:: Forum ::.. Register  Login
 Forum Minimize
Pentru a putea posta mesaje trebuie să vă înregistraţi.
Notă: Mesajele cu conţinut jignitor sau ilegal (inclusiv cereri de soft piratat) nu sunt acceptate şi vor fi şterse imediat .

Pentru a primi raspunsuri rapide si corecte, scrieti in mesaj ce intentionati sa faceti, ce mesaj de eroare primiti, in ce context si in urma caror actiuni. De asemenea, mentionati versiunea de FoxPro in care lucrati!
Dacă nu specificați versiunea, se consideră VFP 9.0 SP2.

SearchForum Home
  Visual FoxPro  Win32 API  CreateProcessAs...
 CreateProcessAsUser fails
 
 9/12/2007 3:51:34 PM
User is offlineghircoiascamil
23 posts
www.info-expert.ro


CreateProcessAsUser fails
 (N/A)
I am using  logonuser api call to access data on a protected folder.
I want to use now CreateProcessAsUser api call to run an external program from my app with the credentials of another user but it does fail
I work on xp machines or vista with vfp 9.0
********************************************
* Example && why CreateProcessAsUser fails
********************************************

lpUser="admin2" && another user on my machine
lpDomain=""
lpPassword="password2" && the password of admin2

* first I obtain nToken for the new process with success

#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
? LogonUser(lpUser,lpDomain,lpPassword,LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, @nToken) && ok,#0

? ImpersonateLoggedOnUser(nToken) && ok,#0
? nToken && #0 so it is ok

* Untill here it works ok, nToken is#0 and access is granted

* Now I want to run an external app as another user

local lpStartupInfo,lcProcInfo
lpStartupInfo = CHR(68) + REPLICATE(CHR(0), 67)
lcProcInfo = REPLICATE(CHR(0), 16)

DECLARE INTEGER CreateProcessAsUser IN advapi32;
INTEGER hToken,;
STRING lpApplicationName,;
STRING lpCommandLine,;
INTEGER lpProcessAttributes,;
INTEGER lpThreadAttributes,;
INTEGER bInheritHandles,;
INTEGER dwCreationFlags,;
INTEGER @lpEnvironment,;
STRING lpCurrentDirectory,;
STRING lpStartupInfo,;
STRING @ lpProcessInformation

? CreateProcessAsUser(nToken,'notepad.exe','',0,0,0,0,0,curdir(),lpStartupInfo,@lcProcInfo)
* result=0, is not working
* instead notepad.exe, you can put cmd.exe...,another app

Please help
 9/27/2007 10:50:30 AM
User is offlineTibisan
269 posts
4th


Re: CreateProcessAsUser fails
 (Romania) Modified By Tibisan  on 9/27/2007 10:53:44 AM)

http://msdn2.microsoft.com/en-us/library/aa379608.aspx

this approach however has a weak spot, mentioned at the end of that post.

  Visual FoxPro  Win32 API  CreateProcessAs...

Search  Forum Home         

 Google Ads Minimize

    

Copyright 2002-2010 Profox   Terms Of Use  Privacy Statement