Corrected based on fix to TOKEN_LINKED_TOKEN.LinkedToken type

pull/83/head
David Hall 2019-08-16 09:56:00 -06:00
parent 92ad7b8abe
commit 8b04dfed0f
1 changed files with 4 additions and 3 deletions

View File

@ -79,7 +79,7 @@ namespace Vanara.Security
if (elevType == TOKEN_ELEVATION_TYPE.TokenElevationTypeLimited)
{
// Marshal the linked token value from native to .NET.
hObjectToCheck = new SafeHTOKEN(hObject.GetInfo<TOKEN_LINKED_TOKEN>(TOKEN_INFORMATION_CLASS.TokenLinkedToken).LinkedToken);
hObjectToCheck = new SafeHTOKEN(hObject.GetInfo<TOKEN_LINKED_TOKEN>(TOKEN_INFORMATION_CLASS.TokenLinkedToken).LinkedToken.DangerousGetHandle());
}
}
@ -95,8 +95,9 @@ namespace Vanara.Security
if (hObjectToCheck == null || hObjectToCheck.IsInvalid) return false;
// Check if the token to be checked contains admin SID.
var id = new WindowsIdentity(hObjectToCheck.DangerousGetHandle());
return id.IsAdmin();
using (hObjectToCheck)
using (var id = new WindowsIdentity(hObjectToCheck.DangerousGetHandle()))
return id.IsAdmin();
}
/*/// <summary>Runs the current application elevated if it isn't already. <note>This will close the current running instance.</note></summary>