Click to See Complete Forum and Search --> : ERROR_NO_TOKEN when trying to open a token in a thread


demuelli
October 20th, 2004, 09:45 AM
I try to open a threadtoken in a thread and set its privileges:

With starting the thread like that:


SECURITY_ATTRIBUTES sa;
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = NULL;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);

hWorkerThread = CreateThread(
&sa,
0,
CreateWorkerThread,
&UInf,
0,
&dwLoginThreadId);


And trying to open the token like that:


if(!OpenThreadToken(
GetCurrentThread(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
TRUE,
&hToken
))
{
printf("Unable to open thread token.\n");
dwLastError = GetLastError();
printf("OpenThreadToken: dwLastError: %0.8x[%d]\n",dwLastError,dwLastError);
return 0;
}


I'm getting the follwing error: 1008 -> An attempt was made to reference a token that does not exist. ERROR_NO_TOKEN.
Any suggestions why this happened and how it can be fixed ?

AdaraCD
October 20th, 2004, 12:41 PM
read this => OpenThreadToken fails... (http://groups.google.com/groups?hl=en&lr=&c2coff=1&threadm=OJ2te2CGAHA.271%40cppssbbsa05&rnum=1&prev=/groups%3Fq%3DERROR_NO_TOKEN%2520%252B%2520OpenThreadToken%26hl%3Den%26lr%3D%26c2coff%3D1%26sa%3DN%26tab%3Dwg)

demuelli
October 21st, 2004, 01:36 AM
It works fine. Thanks a lot, you really helped me very much.