Skip to main content

rusthound_ce/enums/
common.rs

1/// Map the `groupType` attribute to the scope string BloodHound expects.
2///
3/// Only the scope bits matter here; `GROUP_TYPE_SECURITY_ENABLED` (0x80000000)
4/// distinguishes security from distribution groups and is not part of the scope.
5/// <https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts>
6pub fn group_scope(group_type: i64) -> String {
7    const BUILTIN_LOCAL_GROUP: i64 = 0x0000_0001;
8    const ACCOUNT_GROUP: i64 = 0x0000_0002;
9    const RESOURCE_GROUP: i64 = 0x0000_0004;
10    const UNIVERSAL_GROUP: i64 = 0x0000_0008;
11
12    if group_type & UNIVERSAL_GROUP != 0 {
13        "Universal".to_string()
14    } else if group_type & ACCOUNT_GROUP != 0 {
15        "Global".to_string()
16    } else if group_type & (RESOURCE_GROUP | BUILTIN_LOCAL_GROUP) != 0 {
17        "DomainLocal".to_string()
18    } else {
19        String::new()
20    }
21}