Hi,

I am getting a "Invalid Parameter" exception (Error Code 87) when I try to
use SetTokenInformation or GetTokenInformation inside a windows NT Service.
The service is running with administrator rights.

HANDLE hToken;
SECURITY_IMPERSONATION_LEVEL imp_level;
imp_level = SecurityIdentification;
if ( OpenProcessToken( GetCurrentProcess(), TOKEN_WRITE, &hToken))
{
SetTokenInformation( hToken, TokenImpersonationLevel, (LPVOID) &imp_level,
sizeof(imp_level)); //This line returns an error code of 87
}

Has anybody come across this error? Any help will be greatly appreciated.

Thanks,
K

Re: SetTokenInformation by Joe

Joe
Wed Aug 30 20:41:21 CDT 2006

Did you read this carefully

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/settokeninformation.asp

Specifically the remarks.



--
Joe Richards Microsoft MVP Windows Server Directory Services
Author of O'Reilly Active Directory Third Edition
www.joeware.net


---O'Reilly Active Directory Third Edition now available---

http://www.joeware.net/win/ad3e.htm


Kishore wrote:
> Hi,
>
> I am getting a "Invalid Parameter" exception (Error Code 87) when I try to
> use SetTokenInformation or GetTokenInformation inside a windows NT Service.
> The service is running with administrator rights.
>
> HANDLE hToken;
> SECURITY_IMPERSONATION_LEVEL imp_level;
> imp_level = SecurityIdentification;
> if ( OpenProcessToken( GetCurrentProcess(), TOKEN_WRITE, &hToken))
> {
> SetTokenInformation( hToken, TokenImpersonationLevel, (LPVOID) &imp_level,
> sizeof(imp_level)); //This line returns an error code of 87
> }
>
> Has anybody come across this error? Any help will be greatly appreciated.
>
> Thanks,
> K
>
>