< Summary

Class:SharpHoundCommonLib.LdapConfig
Assembly:SharpHoundCommonLib
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\LdapConfig.cs
Covered lines:13
Uncovered lines:24
Coverable lines:37
Total lines:56
Line coverage:35.1% (13 of 37)
Covered branches:2
Total branches:16
Branch coverage:12.5% (2 of 16)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetPort(...)0%1000%
GetGCPort(...)100%20100%
ToString()0%400%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\LdapConfig.cs

#LineLine coverage
 1using System.DirectoryServices.Protocols;
 2using System.Text;
 3
 4namespace SharpHoundCommonLib
 5{
 6    public class LdapConfig
 7    {
 668        public string Username { get; set; } = null;
 609        public string Password { get; set; } = null;
 6110        public string Server { get; set; } = null;
 6011        public int Port { get; set; } = 0;
 6012        public int SSLPort { get; set; } = 0;
 6113        public bool ForceSSL { get; set; } = false;
 6214        public bool DisableSigning { get; set; } = false;
 6215        public bool DisableCertVerification { get; set; } = false;
 6216        public AuthType AuthType { get; set; } = AuthType.Kerberos;
 6017        public int MaxConcurrentQueries { get; set; } = 15;
 18
 19        //Returns the port for connecting to LDAP. Will always respect a user's overridden config over anything else
 20        public int GetPort(bool ssl)
 021        {
 022            if (ssl && SSLPort != 0) {
 023                return SSLPort;
 24            }
 025            if (!ssl && Port != 0)
 026            {
 027                return Port;
 28            }
 29
 030            return ssl ? 636 : 389;
 031        }
 32
 33        public int GetGCPort(bool ssl)
 234        {
 235            return ssl ? 3269 : 3268;
 236        }
 37
 038        public override string ToString() {
 039            var sb = new StringBuilder();
 040            sb.AppendLine($"Server: {Server}");
 041            sb.AppendLine($"LdapPort: {GetPort(false)}");
 042            sb.AppendLine($"LdapSSLPort: {GetPort(true)}");
 043            sb.AppendLine($"ForceSSL: {ForceSSL}");
 044            sb.AppendLine($"AuthType: {AuthType.ToString()}");
 045            sb.AppendLine($"MaxConcurrentQueries: {MaxConcurrentQueries}");
 046            if (!string.IsNullOrWhiteSpace(Username)) {
 047                sb.AppendLine($"Username: {Username}");
 048            }
 49
 050            if (!string.IsNullOrWhiteSpace(Password)) {
 051                sb.AppendLine($"Password: {new string('*', Password.Length)}");
 052            }
 053            return sb.ToString();
 054        }
 55    }
 56}