예제 #1
0
 /// <summary>Converts a domain FQDN to a distinguished.</summary>
 /// <param name="domainFqdn">The domain FQDN.</param>
 /// <returns>The distinguished name representation of the <see cref="Fqdn"/>.</returns>
 private static string ToDistinguishedName(this Fqdn domainFqdn)
 {
     return($"DC={domainFqdn.ToString().Replace(".", ",DC=")}");
 }
예제 #2
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()}");
        }