safe-sid
Safe wrapper for working with SIDs from the Windows API.
Provides the borrowed/owned pair &Sid and SidBuf along with safe helper functions. Byte-compatible with the Windows SID struct. Defines equality and ordering traits so they can be compared and keyed on.
Only depends on the windows-core and windows-link crates by default. If you want to have functions accept and return windows::Win32::Security::PSID, enable the windows-full feature.
Usage
[]
= "0.1"
To accept and return windows::Win32::Security::PSID directly:
[]
= { = "0.1", = ["windows-full"] }
= { = "0.62", = ["Win32_Security"] }
This allows from_psid() to accept the PSID type and enables the as_psid() function. Without it, you can still pass a raw *const c_void to from_psid() and get a similar raw pointer via as_ptr().
Build a SID by hand
let admins = new.unwrap;
assert_eq!;
Build a well-known SID
let local_system = well_known.unwrap;
assert_eq!;
Pass a SID to a Windows API
// Just an example, use Sid::to_string() normally
Fill a SidBuf from a Windows API
Sometimes a SID comes from a Windows API that expects the caller to provide a buffer. You can unsafely acquire a mutable pointer, and are responsible for ensuring it is filled with a valid SID with a correctly matching length.
Note that even if the SID is malformed, dropping SidBuf will still be safe.
License
Licensed under the ISC License.