Acl

Struct Acl 

Source
#[repr(C)]
pub struct Acl { /* private fields */ }
Expand description

An entry in an access control list (ACL).

Implementations§

Source§

impl Acl

Source

pub fn effective_rights(&self, trustee: &Trustee<'_>) -> Result<AccessRights>

Determine what rights the given Trustee has under this ACL

use windows_permissions::{LocalBox, Trustee, Sid, SecurityDescriptor};
use windows_permissions::constants::AccessRights;

// Allow a particular user FA (File All) and give all users FR (File Read)
let sd = "D:(A;;FA;;;S-1-5-20-12345)(A;;FR;;;WD)"
    .parse::<LocalBox<SecurityDescriptor>>().unwrap();
let acl = sd.dacl().unwrap();

let sid1: LocalBox<Sid> = "S-1-5-20-12345".parse().unwrap();
let sid2: LocalBox<Sid> = "WD".parse().unwrap();

let trustee1: Trustee = sid1.as_ref().into();
let trustee2: Trustee = sid2.as_ref().into();

assert_eq!(acl.effective_rights(&trustee1).unwrap(), AccessRights::FileAllAccess);
assert_eq!(acl.effective_rights(&trustee2).unwrap(), AccessRights::FileGenericRead);
Source

pub fn len(&self) -> u32

Determine the number of ACEs in this ACL

use windows_permissions::{LocalBox, SecurityDescriptor};

let sd = "D:(A;;GA;;;S-1-5-20-12345)(A;;GR;;;WD)"
    .parse::<LocalBox<SecurityDescriptor>>().unwrap();

assert_eq!(sd.dacl().unwrap().len(), 2);
Source

pub fn get_ace(&self, index: u32) -> Option<&Ace>

Get an ACE by index

Returns None if there are too few ACEs to satisfy the request.

use windows_permissions::{LocalBox, Sid, SecurityDescriptor};
use windows_permissions::constants::{AceType::*, AccessRights};

let sd = "D:(A;;GA;;;S-1-5-20-12345)(A;;GR;;;WD)"
    .parse::<LocalBox<SecurityDescriptor>>().unwrap();
let acl = sd.dacl().unwrap();

let sid1: LocalBox<Sid> = "S-1-5-20-12345".parse().unwrap();
let sid2: LocalBox<Sid> = "WD".parse().unwrap();

assert_eq!(acl.get_ace(0).unwrap().ace_type(), ACCESS_ALLOWED_ACE_TYPE);
assert_eq!(acl.get_ace(0).unwrap().mask(), AccessRights::GenericAll);
assert_eq!(acl.get_ace(0).unwrap().sid(), Some(&*sid1));

assert_eq!(acl.get_ace(1).unwrap().ace_type(), ACCESS_ALLOWED_ACE_TYPE);
assert_eq!(acl.get_ace(1).unwrap().mask(), AccessRights::GenericRead);
assert_eq!(acl.get_ace(1).unwrap().sid(), Some(&*sid2));

assert!(acl.get_ace(2).is_none());
Source

pub fn revision_level(&self) -> AclRevision

Get the ACL’s revision level

use windows_permissions::{LocalBox, SecurityDescriptor, Acl};
use windows_permissions::constants::AclRevision::*;

let simple_acl_sd: LocalBox<SecurityDescriptor> = "D:(A;;;;;WD)".parse().unwrap();
let complex_acl_sd: LocalBox<SecurityDescriptor> = "D:(OA;;;294be2fb-d1ca-4aa2-aa06-ab98a8b5556d;;WD)".parse().unwrap();

assert_eq!(simple_acl_sd.dacl().unwrap().revision_level(), ACL_REVISION);
assert_eq!(complex_acl_sd.dacl().unwrap().revision_level(), ACL_REVISION_DS);

Trait Implementations§

Source§

impl Debug for Acl

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Acl

§

impl RefUnwindSafe for Acl

§

impl Send for Acl

§

impl Sync for Acl

§

impl Unpin for Acl

§

impl UnwindSafe for Acl

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.