Updated SafePSID.FromToken to use generic GetInfo.

pull/250/head
dahall 2021-10-07 10:33:44 -06:00
parent dec201c90a
commit 1632570deb
1 changed files with 2 additions and 3 deletions

View File

@ -126,9 +126,8 @@ namespace Vanara.PInvoke
/// <returns>A <see cref="SafePSID"/> instance of the user account SID associated with a security token.</returns>
public static SafePSID FromToken(HTOKEN hToken)
{
var hTok = new SafeHTOKEN((IntPtr)hToken, false);
using var pUserToken = hTok.GetInfo(TOKEN_INFORMATION_CLASS.TokenUser);
return new SafePSID(pUserToken.ToStructure<TOKEN_USER>().User.Sid);
using var hTok = new SafeHTOKEN((IntPtr)hToken, false);
return hTok.GetInfo<TOKEN_USER>(TOKEN_INFORMATION_CLASS.TokenUser).User.Sid;
}
/// <summary>Performs an explicit conversion from <see cref="SafePSID"/> to <see cref="IntPtr"/>.</summary>