/// <summary> /// Gets the token's primary group. /// </summary> /// <returns>A WindowsSID instance.</returns> public Sid GetPrimaryGroup() { int retLen; Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, IntPtr.Zero, 0, out retLen); using (MemoryAlloc data = new MemoryAlloc(retLen)) { if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, data, data.Size, out retLen)) { Win32.Throw(); } return(new Sid(data.ReadIntPtr(0))); } }
/// <summary> /// Gets the token's owner. /// </summary> /// <returns>A WindowsSID instance.</returns> public Sid GetOwner() { int retLen; Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, IntPtr.Zero, 0, out retLen); using (MemoryAlloc data = new MemoryAlloc(retLen)) { if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, data, data.Size, out retLen)) { Win32.ThrowLastError(); } return(new Sid(data.ReadIntPtr(0))); } }