use crate::{
error::WindowsUsersError,
utils::{lookup_account_sid, str_to_psid},
};
pub mod well_known_sid;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Sid {
sid: &'static str,
}
impl Sid {
pub const fn as_str(&self) -> &'static str {
self.sid
}
pub fn name(&self) -> Result<String, WindowsUsersError> {
lookup_account_sid(None, str_to_psid(self.sid)?.as_psid()).map(|(name, _, _)| name)
}
}
#[cfg(test)]
mod tests {
use crate::well_known_sid::{ADMINISTRATORS, GUESTS, USERS};
#[test]
fn test_sid_as_str() {
assert_eq!(ADMINISTRATORS.as_str(), "S-1-5-32-544");
assert_eq!(USERS.as_str(), "S-1-5-32-545");
assert_eq!(GUESTS.as_str(), "S-1-5-32-546");
}
}