[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

CreateProcessAsUser gives "Required privilege not held" error

Posted on 2004-08-30
9
Medium Priority
?
23,346 Views
Last Modified: 2013-12-03
Hi,
I am writing code to run an exe using an account other than the currently logged in account. For that I have got token of another user by using LogonUser() and then I try to run my exe using CreateProcessAsUser(). It gives me error 1314: A required privilege is not hel by the client. Which privilege does my user doesnt have. I have even tried to use this method with the Administrator account, but the same problem occurs. My user has the following privileges:

 --------------                   ------------
SeTcbPrivilege                   Act as part of the operating system
SeChangeNotifyPrivilege          Bypass traverse checking
SeShutdownPrivilege              Shut down the system
SeUndockPrivilege                Remove computer from docking station

Which privilege am I missing?

Thanks in advance,
Sarah.
0
Comment
Question by:sarah81
8 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 11938921
At least SE_ASSIGNPRIMARYTOKEN_NAME and maybe SE_INCREASE_QUOTA_NAME.

If you've the rights, you can grant them to yourself with AdjustTokenPrivileges().
0
 
LVL 1

Author Comment

by:sarah81
ID: 11939139
Yeah this what MSDN says that you must have  SE_ASSIGNPRIMARYTOKEN_NAME , SE_INCREASE_QUOTA_NAME and SE_TCB_NAME to use CreateProcessAsUser().

But at the same time, MSDN also says: "The AdjustTokenPrivileges function cannot add new privileges to the access token. It can only enable or disable the token's existing privileges."

And my token [that i got from LogonUser( ) ] doesnt have these rights.
What to do?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 11939441
CreateProcessAsUser usually only works from inside a service.

Can you use CreateProcessWithLogonW? That doesn't need as much privileges. The only problem of this API is that it isn't supported in NT4.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:sarah81
ID: 11939494
I am using Visual Studio 6.0 and Microsoft SDK 2003 on Windows 2000. I have included windows.h in my project,yet it gives "Undeclared identifier" error when I try to use CreateProcessWithLogonW().

I am not sure if the problem is related to services because I am able to successfully logon the other account by using LogonUser().

I think cookre is right, the reason CreateProcessAsUser() fails is that it doesnt have these 2 privileges. But the problem is, I cant find any API to assign a user privileges that arent held by him. And my user holds only the 4 privileges that I mentioned in my question.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 11939537
See here about CreateProcessWithLogonW:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocesswithlogonw.asp

About privileges: If everyone could just assign any privilege to himself, what would privileges be worth anymore? They are meant to be a secure way to limit the rights of a specific user. So of course Microsoft made sure that you can't get around that too easily.
0
 
LVL 1

Author Comment

by:sarah81
ID: 11987247
Ok another problem. CreateProcessAsUser() now works with the Administrator user but for other users, it gives error "The application failed to initialize properly (0xc0000142). Click OKto terminate the application".
Why?? It cant be a privilege problem, becuase in that case it would have given "required privilege not held prob rather than this one"

Does anyone know the solution to this prob?? Why am i getting this error for some users (and not all) and why am i getting this error in the first place?
I am just trying to run cmd.exe from the method.

Thanks.
0
 
LVL 1

Author Comment

by:sarah81
ID: 11988749
I have found solution to all the above problems.

(1) For the first problem (required privileges not held), the privileges were to be assigned to the user who is currently logged on (not the user whom we log on through LogonUser() ). If you are logged through the local Admin, you can always use CreateProcessAsUser without trouble. If you are logged on through someother account,  you wil have to assign yourself the 3 rights  SE_ASSIGNPRIMARYTOKEN_NAME , SE_INCREASE_QUOTA_NAME and SE_TCB_NAME to successfully call LogonUser and CreateProcessAsUser.

(2) As for the "applicaton failed to initialize 0xc0000142" error, its windows security that it doesnt allow someone to user others' account. So you have to go a long way to achieve that.  See Microsoft Knowledge Base Article  Q165194 "INFO: CreateProcessAsUser() Windowstations and Desktops " in the MSDN. It shows how to obtain and SID and then use it for this purpose.


0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12030038
PAQd, 250 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question