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
impl Sid
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
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.
Sourcepub fn as_ptr(&self) -> *const c_void
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.
Sourcepub unsafe fn from_psid<'a>(psid: impl AsSidPtr) -> Result<&'a Sid, Error>
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.
Sourcepub fn revision(&self) -> u8
pub fn revision(&self) -> u8
Returns the SID revision.
Valid Windows SIDs currently have revision 1.
Returns the number of sub-authorities recorded in the SID header.
Returns the 48-bit identifier authority as an integer.
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.
Returns the sub-authority at idx, or None if it is out of bounds.
Sourcepub fn rid(&self) -> Option<u32>
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.
Returns all of the SID’s sub-authorities.
Sourcepub fn equal_prefix(&self, other: &Sid) -> bool
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.
Sourcepub fn equal_domain(&self, other: &Sid) -> Result<bool, Error>
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.
Sourcepub fn account_domain_sid(&self) -> Result<SidBuf, Error>
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.
Sourcepub fn is_well_known(&self, well_known_type: impl AsWellKnownSidType) -> bool
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.