Struct windows_permissions::Sid [−][src]
#[repr(C)]pub struct Sid { /* fields omitted */ }
Expand description
A SID (Security Identifier) that can be used with Windows API calls.
Implementations
impl Sid
[src]
impl Sid
[src]pub fn new(id_auth: [u8; 6], sub_auths: &[u32]) -> Result<LocalBox<Sid>>
[src]
pub fn new(id_auth: [u8; 6], sub_auths: &[u32]) -> Result<LocalBox<Sid>>
[src]Create a new SID from raw parts
use windows_permissions::Sid; let sid_8 = Sid::new([1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6, 7, 8]).unwrap(); assert_eq!(sid_8.id_authority(), &[1, 2, 3, 4, 5, 6]); assert_eq!(sid_8.sub_authority_count(), 8); assert_eq!(sid_8.sub_authorities(), &[1, 2, 3, 4, 5, 6, 7, 8]);
No more than 8 sub-authorities can be made using this function. If more are needed, you can parse SDDL or use a wrapper function directly.
use windows_permissions::Sid; assert!(Sid::new([1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6, 7, 8]).is_ok()); assert!(Sid::new([1, 2, 3, 4, 5, 6], &[1, 2, 3, 4, 5, 6, 7, 8, 9]).is_err());
pub fn well_known_sid(well_known_sid_type: u32) -> Result<LocalBox<Sid>>
[src]
pub fn well_known_sid(well_known_sid_type: u32) -> Result<LocalBox<Sid>>
[src]Create a new well-known SID
This is equivalent to calling wrappers::CreateWellKnownSid
with
None
as the domain.
use windows_permissions::{Sid, LocalBox}; use winapi::um::winnt::WinWorldSid; let win_world_sid = Sid::well_known_sid(WinWorldSid).unwrap(); let another_sid = "S-1-1-0".parse().unwrap(); assert_eq!(win_world_sid, another_sid);
pub fn sub_authority_count(&self) -> u8
[src]
pub fn sub_authority_count(&self) -> u8
[src]Get the number of sub-authorities in the SID
use windows_permissions::{Sid, LocalBox}; let sid1: LocalBox<Sid> = "S-1-5-1".parse().unwrap(); let sid2: LocalBox<Sid> = "S-1-5-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15".parse().unwrap(); assert_eq!(sid1.sub_authority_count(), 1); assert_eq!(sid2.sub_authority_count(), 15);
pub fn id_authority(&self) -> &[u8; 6]
[src]
pub fn id_authority(&self) -> &[u8; 6]
[src]Get the ID authority of the SID
use windows_permissions::{Sid, LocalBox}; let sid1: LocalBox<Sid> = "S-1-5-12-62341".parse().unwrap(); let sid2: LocalBox<Sid> = "S-1-211111900160837-1".parse().unwrap(); assert_eq!(sid1.id_authority(), &[0, 0, 0, 0, 0, 5]); assert_eq!(sid2.id_authority(), &[0xC0, 0x01, 0x51, 0xD1, 0x23, 0x45]);
pub fn sub_authority(&self, index: u8) -> Option<u32>
[src]
pub fn sub_authority(&self, index: u8) -> Option<u32>
[src]Get a sub-authority of the SID if it is available
Returns None
if the SID has too few sub-authorities.
use windows_permissions::{Sid, LocalBox}; let sid: LocalBox<Sid> = "S-1-5-12-62341".parse().unwrap(); assert_eq!(sid.sub_authority(0), Some(12)); assert_eq!(sid.sub_authority(1), Some(62341)); assert_eq!(sid.sub_authority(2), None);
pub fn sub_authorities(&self) -> Vec<u32>
[src]
pub fn sub_authorities(&self) -> Vec<u32>
[src]Generate a list of the sub-authorities in the SID
Changes in the returned Vec
are not reflected in the SID
Trait Implementations
impl Eq for Sid
[src]
Auto Trait Implementations
impl RefUnwindSafe for Sid
impl Send for Sid
impl Sync for Sid
impl Unpin for Sid
impl UnwindSafe for Sid
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more