public EnvironmentBlock(TokenHandle tokenHandle) { if (!Win32.CreateEnvironmentBlock(out _environment, tokenHandle, false)) { Win32.Throw(); } }
public static TokenHandle Create( TokenAccess access, ObjectFlags objectFlags, TokenHandle existingTokenHandle, TokenType tokenType, Sid user, Sid[] groups, PrivilegeSet privileges, Sid owner, Sid primaryGroup ) { var statistics = existingTokenHandle.GetStatistics(); return(Create( access, null, objectFlags, null, tokenType, statistics.AuthenticationId, statistics.ExpirationTime, user, groups, privileges, owner, primaryGroup, null, _phTokenSource )); }
public static TokenHandle OpenSystemToken(TokenAccess access, SecurityImpersonationLevel impersonationLevel, TokenType type) { using (ProcessHandle phandle = new ProcessHandle(4, OSVersion.MinProcessQueryInfoAccess)) { using (TokenHandle thandle = phandle.GetToken(TokenAccess.Duplicate | access)) { return(thandle.Duplicate(access, impersonationLevel, type)); } } }
public static TokenHandle Create( TokenAccess access, TokenType tokenType, Sid user, Sid[] groups, PrivilegeSet privileges ) { using (var administratorsSid = Sid.GetWellKnownSid(WellKnownSidType.WinBuiltinAdministratorsSid)) using (var thandle = TokenHandle.OpenCurrentPrimary(TokenAccess.Query)) return(Create(access, 0, thandle, tokenType, user, groups, privileges, administratorsSid, administratorsSid)); }
/// <summary> /// Determins whether the token is the same as another token. /// </summary> /// <param name="other">The other token.</param> /// <returns>Whether they are equal.</returns> public bool Equals(TokenHandle other) { bool equal; Win32.NtCompareTokens( this, other, out equal ).ThrowIf(); return(equal); }
/// <summary> /// Determins whether the token is the same as another token. /// </summary> /// <param name="other">The other token.</param> /// <returns>Whether they are equal.</returns> public bool Equals(TokenHandle other) { NtStatus status; bool equal; if ((status = Win32.NtCompareTokens( this, other, out equal )) >= NtStatus.Error) { Win32.Throw(status); } return(equal); }
public TokenWithLinkedToken(TokenHandle token) { _token = token; }
/// <summary> /// Sets the thread's impersonation token. /// </summary> /// <param name="tokenHandle"> /// A handle to a token. Specify null to cause the thread to stop /// impersonating. /// </param> public void SetToken(TokenHandle tokenHandle) { this.SetInformationIntPtr(ThreadInformationClass.ThreadImpersonationToken, tokenHandle ?? IntPtr.Zero); }