From: nki00 on
I've been told earlier that to determine if the current process is running
in a Guest account I need to call
OpenProcessToken
GetTokenInformation

But what parameters should I actually call it with?


From: Jackie on
nki00 wrote:
> I've been told earlier that to determine if the current process is running
> in a Guest account I need to call
> OpenProcessToken
> GetTokenInformation
>
> But what parameters should I actually call it with?
>
>

I think this should be possible with the CreateWellKnownSid API and then
CheckTokenMembership or GetTokenInformation. CheckTokenMembership would
be easier to use. I'm working on an example now for some reason.

--
Regards,
Jackie
From: Jackie on
Jackie wrote:
> nki00 wrote:
>> I've been told earlier that to determine if the current process is
>> running
>> in a Guest account I need to call
>> OpenProcessToken
>> GetTokenInformation
>>
>> But what parameters should I actually call it with?
>>
>>
>
> I think this should be possible with the CreateWellKnownSid API and then
> CheckTokenMembership or GetTokenInformation. CheckTokenMembership would
> be easier to use. I'm working on an example now for some reason.
>

Okay, here it is:
http://pastebin.com/gmtLbZN5

Now, I am not sure exactly why CheckTokenMembership fails and
GetLastError returns INVALID_HANDLE_VALUE when you try this as a limited
user. Works fine as an elevated user. Maybe I'm not asking for the
access needed or we need more privileges. Either way, it should give you
a clue on how to begin. :)

--
Regards,
Jackie
From: nki00 on
> Okay, here it is:
> http://pastebin.com/gmtLbZN5
>
> Now, I am not sure exactly why CheckTokenMembership fails and GetLastError
> returns INVALID_HANDLE_VALUE when you try this as a limited user. Works
> fine as an elevated user. Maybe I'm not asking for the access needed or we
> need more privileges. Either way, it should give you a clue on how to
> begin. :)
>
> --
> Regards,
> Jackie



Cool, thanks. I'll work on it a bit more tomorrow (it's too late now) and
will post what I find.

In the meantime, I'm curious, why are you calling DuplicateToken() on a
token?


From: Jackie on
nki00 wrote:
>> Okay, here it is:
>> http://pastebin.com/gmtLbZN5
>>
>> Now, I am not sure exactly why CheckTokenMembership fails and GetLastError
>> returns INVALID_HANDLE_VALUE when you try this as a limited user. Works
>> fine as an elevated user. Maybe I'm not asking for the access needed or we
>> need more privileges. Either way, it should give you a clue on how to
>> begin. :)
>>
>> --
>> Regards,
>> Jackie
>
>
>
> Cool, thanks. I'll work on it a bit more tomorrow (it's too late now) and
> will post what I find.
>
> In the meantime, I'm curious, why are you calling DuplicateToken() on a
> token?
>
>

The very short answer: If you don't, you will get some sort of "no
impersonation token" error when calling CheckTokenMembership.

--
Regards,
Jackie