I have a c++ application in which threads could impersonate using LogonUser/ImpersonateLoggedOnUser, and then revert impersonation using RevertToSelf. I ran across the bug which caused thread to impersonate this way twice. I want to prevent this by testing if current thread is already impersonating and throw exception if it is. Is there a way to tell if current thread is impersonating already?
I have a c++ application in which threads could impersonate using LogonUser/ImpersonateLoggedOnUser, and then
Share
You can use OpenThreadToken. If a thread has a token then it is impersonating; if it doesn’t have a token then it is not impersonating.