Solved

CreateProcessAsUser gives "Required privilege not held" error

Posted on 2004-08-30
9
23,194 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
9 Comments
 
LVL 22

Expert Comment

by:cookre
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:sarah81
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQd, 250 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now