pub struct Token(/* private fields */);Expand description
Strongly-typed RAII guard holding an open process or thread token handle.
Implementations§
Source§impl Token
impl Token
Sourcepub fn current() -> Result<Self, ElevateError>
pub fn current() -> Result<Self, ElevateError>
Open the token belonging to the current application process.
Sourcepub fn from_pid(pid: u32) -> Result<Self, ElevateError>
pub fn from_pid(pid: u32) -> Result<Self, ElevateError>
Open the security token belonging to an arbitrary running process by PID.
Sourcepub fn duplicate(&self, token_type: TokenType) -> Result<Self, ElevateError>
pub fn duplicate(&self, token_type: TokenType) -> Result<Self, ElevateError>
Duplicate this token as either a Primary or Impersonation token.
Sourcepub fn enable_privileges(
&self,
privileges: &[Privilege],
) -> Result<(), ElevateError>
pub fn enable_privileges( &self, privileges: &[Privilege], ) -> Result<(), ElevateError>
Enable the specified administrative privileges on this token.
Sourcepub fn session_id(&self) -> Result<u32, ElevateError>
pub fn session_id(&self) -> Result<u32, ElevateError>
Query the Windows Session ID currently associated with this token.
Sourcepub fn set_session_id(&self, session_id: u32) -> Result<(), ElevateError>
pub fn set_session_id(&self, session_id: u32) -> Result<(), ElevateError>
Explicitly assign a Windows Session ID to this token.
Sourcepub fn impersonate(&self) -> Result<ImpersonationGuard, ElevateError>
pub fn impersonate(&self) -> Result<ImpersonationGuard, ElevateError>
Impersonate this token on the current thread, returning an RAII revert guard.
Sourcepub fn user_sid(&self) -> Result<String, ElevateError>
pub fn user_sid(&self) -> Result<String, ElevateError>
Retrieve the owner user SID string of this token.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Token
impl !Sync for Token
impl Freeze for Token
impl RefUnwindSafe for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more