Skip to main content

Sid

Struct Sid 

Source
pub struct Sid { /* private fields */ }
Expand description

A borrowed SID.

Sid is byte-compatible with the Windows SID structure but represented as a dynamically sized type. It is normally obtained by dereferencing a SidBuf or, when borrowing memory owned elsewhere, by calling Sid::from_psid.

Use ToOwned::to_owned to copy a borrowed SID into a SidBuf.

Implementations§

Source§

impl Sid

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Returns the logical SID as raw bytes.

The slice contains the eight-byte header followed by four bytes for each sub-authority. Spare capacity in a SidBuf::with_capacity allocation is not included.

Source

pub fn as_ptr(&self) -> *const c_void

Returns a raw pointer to this SID for use with Windows APIs.

The pointer remains valid only while self is alive and has not been mutably borrowed. The called API must not mutate the SID through it.

Source

pub unsafe fn from_psid<'a>(psid: impl AsSidPtr) -> Result<&'a Sid, Error>

Borrows a raw PSID as &'a Sid, validating its structure.

§Safety

psid must be non-null and point to a readable, 4-byte-aligned SID that remains valid for 'a. Its sub-authority count must accurately describe the allocation. SIDs allocated by Windows meet these requirements.

§Errors

Returns Error::InvalidSid if the revision or sub-authority count is outside the range allowed by Windows.

Source

pub fn revision(&self) -> u8

Returns the SID revision.

Valid Windows SIDs currently have revision 1.

Source

pub fn sub_authority_count(&self) -> u8

Returns the number of sub-authorities recorded in the SID header.

Source

pub fn authority(&self) -> u64

Returns the 48-bit identifier authority as an integer.

Source

pub fn authority_bytes(&self) -> [u8; 6]

Returns the identifier authority in its big-endian six-byte form.

This is the representation used by the constants in authority and accepted by SidBuf::new.

Source

pub fn sub_authority(&self, idx: u8) -> Option<u32>

Returns the sub-authority at idx, or None if it is out of bounds.

Source

pub fn rid(&self) -> Option<u32>

Returns the SID’s relative identifier (RID).

A RID is the final sub-authority. Returns None when the SID has no sub-authorities.

Source

pub fn sub_authorities(&self) -> &[u32]

Returns all of the SID’s sub-authorities.

Source

pub fn equal_prefix(&self, other: &Sid) -> bool

Tests whether this SID and other have equal prefixes.

A SID prefix contains the revision, identifier authority, sub-authority count, and every sub-authority except the last.

Source

pub fn equal_domain(&self, other: &Sid) -> Result<bool, Error>

Tests whether this SID and other belong to the same Windows account domain.

Calls the Windows EqualDomainSid function.

Both SIDs must be account-domain SIDs or BUILTIN SIDs.

§Errors

Returns the error reported by EqualDomainSid.

Source

pub fn account_domain_sid(&self) -> Result<SidBuf, Error>

Returns the Windows account-domain SID containing this SID.

Calls the Windows GetWindowsAccountDomainSid function.

§Errors

Returns the error reported by GetWindowsAccountDomainSid.

Source

pub fn is_well_known(&self, well_known_type: impl AsWellKnownSidType) -> bool

Tests whether this SID has the specified well-known SID type.

Calls the Windows IsWellKnownSid function.

Trait Implementations§

Source§

impl AsRef<Sid> for SidBuf

Source§

fn as_ref(&self) -> &Sid

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<Sid> for SidBuf

Source§

fn borrow(&self) -> &Sid

Immutably borrows from an owned value. Read more
Source§

impl Debug for Sid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Sid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Sid

Source§

impl Hash for Sid

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl Ord for Sid

Source§

fn cmp(&self, other: &Sid) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for Sid

Source§

fn eq(&self, other: &Sid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&Sid> for SidBuf

Source§

fn eq(&self, other: &&Sid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<Sid> for SidBuf

Source§

fn eq(&self, other: &Sid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<SidBuf> for Sid

Source§

fn eq(&self, other: &SidBuf) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<SidBuf> for &Sid

Source§

fn eq(&self, other: &SidBuf) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Sid

Source§

fn partial_cmp(&self, other: &Sid) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToOwned for Sid

Source§

type Owned = SidBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> SidBuf

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

§

impl !Sized for Sid

§

impl Freeze for Sid

§

impl RefUnwindSafe for Sid

§

impl Send for Sid

§

impl Sync for Sid

§

impl Unpin for Sid

§

impl UnsafeUnpin for Sid

§

impl UnwindSafe for Sid

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more