You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting Error Code 1312 for the below code so How to fix the Win32 API function error: 1312 (GetTokenInformation) occurring for the below code used for creating a windows installer application.
#363
Open
prmjh4 opened this issue
Sep 10, 2024
· 0 comments
I have used the below code and it is working fine for most of the cases while using the windows installer but for one windows machine it is failing at the section where we call 'GetTokenInformation' win32 API function and throws an error as ERROR: API = GetTokenInformation, error code = 1312, message = A specified logon session does not exist. It may already have been terminated.)
What could have gone wrong and how can we resolve this. Please help. Thanks!
`// Logging on as the passed ssh user (not logged in user) which is non-Administrator
if (!LogonUser(username.c_str(), domain.c_str(), password.c_str(), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hToken)) {
DisplayError(L"LogonUser");
goto Cleanup;
}
tokenUsed = hToken;
// If the ssh user (not logged in user) is non-Administrator, we need linked token
if (!adminUser)
{
if (!GetTokenInformation(hToken, TokenLinkedToken, &linkedToken, sizeof(TOKEN_LINKED_TOKEN), &returnLength))
{
DisplayError(L"GetTokenInformation");
goto Cleanup;
}
// Duplicate the token to ensure valid usage
if (!DuplicateTokenEx(linkedToken.LinkedToken, MAXIMUM_ALLOWED, NULL, SecurityIdentification, TokenPrimary, &hDupToken)) {
DisplayError(L"DuplicateTokenEx");
goto Cleanup;
}
tokenUsed = hDupToken; // Use the duplicated token
}`
The text was updated successfully, but these errors were encountered:
I have used the below code and it is working fine for most of the cases while using the windows installer but for one windows machine it is failing at the section where we call 'GetTokenInformation' win32 API function and throws an error as ERROR: API = GetTokenInformation, error code = 1312, message = A specified logon session does not exist. It may already have been terminated.)
What could have gone wrong and how can we resolve this. Please help. Thanks!
`// Logging on as the passed ssh user (not logged in user) which is non-Administrator
if (!LogonUser(username.c_str(), domain.c_str(), password.c_str(), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hToken)) {
DisplayError(L"LogonUser");
goto Cleanup;
}
The text was updated successfully, but these errors were encountered: