| | 1 | | using System; |
| | 2 | | using System.DirectoryServices.Protocols; |
| | 3 | | using System.Threading; |
| | 4 | | using SharpHoundCommonLib.Enums; |
| | 5 | |
|
| | 6 | | namespace SharpHoundCommonLib { |
| | 7 | | public class LdapQueryParameters { |
| | 8 | | private static int _queryIDIndex; |
| | 9 | | private string _searchBase; |
| | 10 | | private string _relativeSearchBase; |
| 42 | 11 | | public string LDAPFilter { get; set; } |
| 42 | 12 | | public SearchScope SearchScope { get; set; } = SearchScope.Subtree; |
| 75 | 13 | | public string[] Attributes { get; set; } = Array.Empty<string>(); |
| 39 | 14 | | public string DomainName { get; set; } |
| 3 | 15 | | public bool GlobalCatalog { get; set; } |
| 37 | 16 | | public bool IncludeSecurityDescriptor { get; set; } = false; |
| 37 | 17 | | public bool IncludeDeleted { get; set; } = false; |
| 1 | 18 | | private int QueryID { get; } |
| | 19 | |
|
| 74 | 20 | | public LdapQueryParameters() { |
| 37 | 21 | | QueryID = _queryIDIndex; |
| 37 | 22 | | Interlocked.Increment(ref _queryIDIndex); |
| 37 | 23 | | } |
| | 24 | |
|
| | 25 | | public string SearchBase { |
| 1 | 26 | | get => _searchBase; |
| 7 | 27 | | set { |
| 7 | 28 | | _relativeSearchBase = null; |
| 7 | 29 | | _searchBase = value; |
| 7 | 30 | | } |
| | 31 | | } |
| | 32 | |
|
| | 33 | | public string RelativeSearchBase { |
| 0 | 34 | | get => _relativeSearchBase; |
| 0 | 35 | | set { |
| 0 | 36 | | _relativeSearchBase = value; |
| 0 | 37 | | _searchBase = null; |
| 0 | 38 | | } |
| | 39 | | } |
| | 40 | |
|
| 64 | 41 | | public NamingContext NamingContext { get; set; } = NamingContext.Default; |
| | 42 | |
|
| | 43 | | public string GetQueryInfo() |
| 1 | 44 | | { |
| 1 | 45 | | return $"Query Information - Filter: {LDAPFilter}, Domain: {DomainName}, GlobalCatalog: {GlobalCatalog}, ADS |
| 1 | 46 | | } |
| | 47 | | } |
| | 48 | | } |