Example #1
0
        /// <summary>Converts a FQDN to an LDAP connection string.</summary>
        /// <param name="domainFqdn">The domain FQDN.</param>
        /// <param name="domainControllerFqdn">The domain controller FQDN to use in this domain. (NOTE: this can be an IP address).</param>
        /// <returns>An LDAP formatted connection string.</returns>
        public static string ToLdapConnectionString(this Fqdn domainFqdn, string domainControllerFqdn)
        {
            if (!IPAddress.TryParse(domainControllerFqdn, out IPAddress ip) && !domainControllerFqdn.ContainsCaseInsensitive(domainFqdn.ToString()))
            {
                throw new ArgumentException($"The {nameof(domainControllerFqdn)} must be in the same domain as the {nameof(domainFqdn)}", nameof(domainControllerFqdn));
            }

            return($"LDAP://{domainControllerFqdn}/{domainFqdn.ToDistinguishedName()}");
        }
Example #2
0
 /// <summary>Converts a FQDN to an LDAP connection string.</summary>
 /// <param name="domainFqdn">The domain FQDN.</param>
 /// <returns>An LDAP formatted connection string.</returns>
 public static string ToLdapConnectionString(this Fqdn domainFqdn)
 {
     return($"LDAP://{domainFqdn}/{domainFqdn.ToDistinguishedName()}");
 }