Click here to Skip to main content
15,915,160 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: is this wright? Pin
Ravi Bhavnani30-Apr-02 9:04
professionalRavi Bhavnani30-Apr-02 9:04 
AnswerRe: is this wright? Pin
Philippe Mori30-Apr-02 13:11
Philippe Mori30-Apr-02 13:11 
QuestionAm I reaching a limit? Pin
lucy30-Apr-02 6:13
lucy30-Apr-02 6:13 
AnswerRe: Am I reaching a limit? Pin
TBK30-Apr-02 6:45
TBK30-Apr-02 6:45 
GeneralRe: Am I reaching a limit? Pin
lucy30-Apr-02 7:02
lucy30-Apr-02 7:02 
GeneralRe: Am I reaching a limit? Pin
Tim Smith30-Apr-02 7:08
Tim Smith30-Apr-02 7:08 
GeneralRe: Am I reaching a limit? Pin
lucy30-Apr-02 8:21
lucy30-Apr-02 8:21 
GeneralCreateProcess - file privileges Pin
30-Apr-02 5:54
suss30-Apr-02 5:54 
K I know theres loads on this topic but couldnt find anything which solves my dilemma.

I have a multi-threaded service with a time event which is monitored using cached information in a singleton com object i then wish to launch a process in a given directory i.e. zip some files up - Scheduler kindof app.

Now my problem is I've been using CreateProcess with no probs - however here it comes if I set the directory for which I wish to launch the process to have permissions for only a certain user - ie full control and i remove the everyone group then I get the error:

"the client does not have the required permissions." Frown | :(

Now I get this error
1: When Im debugging the service i.e. Im logged in as fred, and fred has the full access permissions on the directory in question.

2: When I set the service to use the same account and not the system account.

Now I looked into CreateProcessAsUser using LoginUser with the token - same problem. Not the best solution if it worked as i dont wish to pass or store the login credentials would much rather use the security credentials of the process so hence looked at: GetCurrentProcess, OpenProcessToken and AdjustTokenPrivileges. Still to no avail now i know i must be doing some wrong and missing something obvious so would appreciate any help.

Heres a snippet not clean but general idea:


HANDLE HToken = NULL;
DWORD dwAccess = TOKEN_ALL_ACCESS;

HANDLE hServProcess = GetCurrentProcess ();

if (OpenProcessToken (hServProcess, dwAccess, &HToken))
{
LUID luid;
TOKEN_PRIVILEGES newState, oldState;
DWORD rl;

LookupPrivilegeValue (_T(""), SE_SECURITY_NAME, &luid);
newState.PrivilegeCount = 1;
newState.Privileges[0].Luid = luid;
newState.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

if (!AdjustTokenPrivileges (HToken, FALSE, &newState
, sizeof(oldState), &oldState, &rl))
{
rl = GetLastError();
return rl;
}

// execute zip process
if(CreateProcessAsUser(HToken
, NULL
, settings
, NULL
, NULL
, TRUE
, CREATE_NO_WINDOW
, NULL
, m_pSchedule->DirectoryBuff
, &st
, &proc) == 0);

}


Many thx to anyone who responds - sorry its a long post
GeneralRe: CreateProcess - file privileges Pin
Phil.Benson30-Apr-02 8:19
professionalPhil.Benson30-Apr-02 8:19 
GeneralRe: CreateProcess - file privileges Pin
Ram Cronus1-May-02 0:22
Ram Cronus1-May-02 0:22 
GeneralRe: CreateProcess - file privileges Pin
Phil.Benson1-May-02 21:51
professionalPhil.Benson1-May-02 21:51 
GeneralRe: CreateProcess - file privileges Pin
Ram Cronus2-May-02 4:34
Ram Cronus2-May-02 4:34 
GeneralConvert int to CString Pin
30-Apr-02 5:24
suss30-Apr-02 5:24 
GeneralRe: Convert int to CString Pin
Mike Zinni30-Apr-02 5:31
Mike Zinni30-Apr-02 5:31 
GeneralGet Integer Value from database Pin
30-Apr-02 5:52
suss30-Apr-02 5:52 
GeneralRe: Get Integer Value from database Pin
Nish Nishant30-Apr-02 6:03
sitebuilderNish Nishant30-Apr-02 6:03 
GeneralRe: Get Integer Value from database Pin
Alexandru Savescu30-Apr-02 6:29
Alexandru Savescu30-Apr-02 6:29 
GeneralRe: Get Integer Value from database Pin
Tom Archer30-Apr-02 7:43
Tom Archer30-Apr-02 7:43 
GeneralRe: Convert int to CString Pin
1-May-02 20:10
suss1-May-02 20:10 
GeneralLogin dialog problem Pin
solini30-Apr-02 5:23
solini30-Apr-02 5:23 
GeneralRe: Login dialog problem Pin
Thomas Freudenberg30-Apr-02 5:37
Thomas Freudenberg30-Apr-02 5:37 
GeneralRe: Login dialog problem Pin
Joaquín M López Muñoz30-Apr-02 5:39
Joaquín M López Muñoz30-Apr-02 5:39 
GeneralRe: Login dialog problem Pin
l a u r e n30-Apr-02 8:09
l a u r e n30-Apr-02 8:09 
GeneralRe: Login dialog problem - Solved Pin
30-Apr-02 8:16
suss30-Apr-02 8:16 
QuestionHowto change background color without redrawing content ? Pin
Brian van der Beek30-Apr-02 5:20
Brian van der Beek30-Apr-02 5:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.