diff --git a/src/CommonLib/Cache.cs b/src/CommonLib/Cache.cs index d34eb514..e3ba46f2 100644 --- a/src/CommonLib/Cache.cs +++ b/src/CommonLib/Cache.cs @@ -85,11 +85,6 @@ internal static bool GetMachineSid(string key, out string value) return false; } - internal static void AddConvertedValue(string key, string value) - { - CacheInstance?.ValueToIdCache.TryAdd(key, value); - } - internal static void AddPrefixedValue(string key, string domain, string value) { CacheInstance?.ValueToIdCache.TryAdd(GetPrefixKey(key, domain), value); @@ -112,13 +107,6 @@ internal static bool GetGCCache(string key, out string[] value) return false; } - internal static bool GetConvertedValue(string key, out string value) - { - if (CacheInstance != null) return CacheInstance.ValueToIdCache.TryGetValue(key, out value); - value = null; - return false; - } - internal static bool GetPrefixedValue(string key, string domain, out string value) { if (CacheInstance != null) diff --git a/src/CommonLib/ILdapUtils.cs b/src/CommonLib/ILdapUtils.cs index 7f6d3703..aafcdbfc 100644 --- a/src/CommonLib/ILdapUtils.cs +++ b/src/CommonLib/ILdapUtils.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Security.Principal; using System.Threading; @@ -5,7 +6,7 @@ using SharpHoundCommonLib.OutputTypes; namespace SharpHoundCommonLib { - public interface ILdapUtils { + public interface ILdapUtils : IDisposable { IAsyncEnumerable> Query(LdapQueryParameters queryParameters, CancellationToken cancellationToken = new()); diff --git a/src/CommonLib/LdapUtils.cs b/src/CommonLib/LdapUtils.cs index ad5f1601..60c9e116 100644 --- a/src/CommonLib/LdapUtils.cs +++ b/src/CommonLib/LdapUtils.cs @@ -1213,6 +1213,7 @@ public bool GetDomain(out Domain domain) { } } + Cache.AddGCCache(name, sids.ToArray()); return (true, sids.ToArray()); } @@ -1442,5 +1443,9 @@ public void SetLdapConfig(LDAPConfig config) { public Task<(bool Success, string Message)> TestLdapConnection(string domain) { return _connectionPool.TestDomainConnection(domain, false); } + + public void Dispose() { + _connectionPool?.Dispose(); + } } } \ No newline at end of file