-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathDomainControllerRegistry.cs
More file actions
30 lines (24 loc) · 1.3 KB
/
DomainControllerRegistry.cs
File metadata and controls
30 lines (24 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections.Generic;
namespace SharpHoundCommonLib;
/// <summary>
/// Thread-safe registry of known domain controller SIDs, shared across all LdapUtils instances.
/// Extracted from LdapUtils to give DC tracking a single, focused home.
/// </summary>
internal class DomainControllerRegistry {
// Static backing store intentionally mirrors the original LdapUtils static field so that
// cross-instance visibility is preserved (same behaviour as before extraction).
private static ConcurrentHashSet _domainControllers = new(System.StringComparer.OrdinalIgnoreCase);
/// <summary>Adds a SID to the registry. No-op if already present.</summary>
public void Add(string sid) => _domainControllers.Add(sid);
/// <summary>Returns true if the SID is a known domain controller.</summary>
public bool Contains(string sid) => _domainControllers.Contains(sid);
/// <summary>Returns all registered domain controller SIDs.</summary>
public IEnumerable<string> Values() => _domainControllers.Values();
/// <summary>
/// Resets the registry to an empty state.
/// Called by <see cref="LdapUtils.ResetUtils"/> to support test isolation.
/// </summary>
public void Reset() {
_domainControllers = new ConcurrentHashSet(System.StringComparer.OrdinalIgnoreCase);
}
}