Re: ImpersonateLoggedOnUser & ShellExecute

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Kellie,

thanks for your guidance and patience.
I'm pretty new to the Win32 process & token concept, so forgive my
ignorance.

So, now I've made sure that the calling account has the required privileges
(SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME):
I've set them manually in the control center, and - just to be sure - enable
them with AdjustTokenPrivileges() before calling LogonUser()

What I'm not sure about is, how to set TOKEN_QUERY, TOKEN_DUPLICATE, and
TOKEN_ASSIGN_PRIMARY

I received my token handle with LogonUser()/LogoUserEx() but did not see an
option to set the needed access rights there.
There also are the OpenProcessToken()/OpenThreadToken() functions, where I
can set these privileges - but these APIs create a new token.
Hence, I've tried generating a new token by calling
OpenProcessToken( GetCurrentProcess(),
TOKEN_QUERY OR TOKEN_DUPLICATE OR TOKEN_ASSIGN_PRIMARY,
tokHandle2)
after ImpersonateLoggedOnUser(), but then I get error 5 (Access denied)



Confused,

Wolfgang







"Kellie Fitton" <KELLIEFITTON@xxxxxxxxx> wrote in message
news:1130789102.685736.108930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> The functions LogonUser() and LogonUserEx() are practically the
> same, however, the latter has an advantage of providing the user's
> security identifier (SID), that can be used in a subsequent calls.
>
> The answer to your question depends on the relationship between the
> privileges and the access rights, access rights are having access
> to an object and typically controlled by ACL, on the other hand,
> privileges are granted to a user along with a constructed token,
> to store the user's granted privileges.
>
> According to microSoft, you have to enable or change the granted
> privileges to use a specific function call. Also, it has to do with
> the access rights to the process's access tokens, if you doNot have
> the needed access rights, you can still do whatever you want, as long
> as, you have been granted the special privileges.
>
> Also, once a privilege is granted to the user, it will have two states,
> either Enabled or Disabled. Most privileges are disabled by default,
> and that will require the application program to explicitly turn them
> on, in order to be able to use them.
>
> That said, the function CreateProcessAsUser() had failed because
> the user's token does not have the needed access rights, which are
> the TOKEN_QUERY, TOKEN_DUPLICATE, and TOKEN_ASSIGN_PRIMARY, moreover,
> the process that calls the API CreateProcessAsUser(), must have the
> SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME privileges.
>
> So, another valid option is using the API CreateProcessWithLogonW(),
> this would spawn your application in the correct security context,
> and the function does exactly the same thing as LogonUserEx() and
> CreateProcessAsUser(), and does not require any special privileges,
> just make sure that the account you specify is allowed to logIn
> interactively to your machine, you check that in the domain/local
> policies.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocesswithlogonw.asp
>
> Good luck,
>
> Kellie.
>


.



Relevant Pages

  • Re: Getting logged in user from a service?
    ... That would be surprising considering that privileges can't be added to an existing token since tokens are mostly immutable. ... His own token, if he specifies "Impersonation" when creating an instance of a WMI class, then all he can do is specified by his own privileges. ... That way it's possible to perform some administrative tasks without you, the client, to run as an administrator, you are simply delegating the task to another more privileged process, which on it's turn is rather restricted. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: LoadUserProfile( ) fails with system error code 5(ACCESS_DENIED)
    ... You are not cleaning the profile struct before calling the LoadUserProfile, ... for access tokens, ... // Enable the privilege or disable all privileges. ...
    (microsoft.public.vc.language)
  • Re: Setting SeSecurityPrivilege on IWbemServices in C++
    ... (not all tokens have all the privileges) ... and if you check the "enable-all-privileges" check-box, ... >>> All the code snippets I've found by now are in VB but I need to to it ...
    (microsoft.public.win32.programmer.wmi)
  • Roles Engineering for Active Directory
    ... Automatic Roles Engineering for Active Directory ... We have developed a unique technology that enables reverse engineering of ... the existing access rights and data stored in Active Directory into Logical ... Any insert change or delete in users' privileges. ...
    (comp.os.ms-windows.nt.admin.security)
  • Re: Setting SeSecurityPrivilege on IWbemServices in C++
    ... If you are local administrator of the Domain Controller, ... non-enabled privileges are stripped away across a LRPC ... >> (not all tokens have all the privileges) ...
    (microsoft.public.win32.programmer.wmi)