Esempio n. 1
0
        /// <summary>Converts an FQDN and distinguished name to an LDAP connection string.</summary>
        /// <param name="domainFqdn">The domain FQDN.</param>
        /// <param name="dn">The distinguished name.</param>
        /// <returns>An LDAP connection string.</returns>
        /// <exception cref="System.ArgumentException">If the <paramref name="domainFqdn"/>is not a valid FQDN.</exception>
        public static string ToLdapDNConnectionString(this string domainFqdn, string dn)
        {
            var fqdnResult = Fqdn.Create(domainFqdn);

            if (fqdnResult.IsFailure)
            {
                throw new ArgumentException(fqdnResult.Error, nameof(domainFqdn));
            }

            return(fqdnResult.Value.ToLdapDNConnectionString(dn));
        }
Esempio n. 2
0
        /// <summary>Converts a FQDN and SID to a LDAP connection string.</summary>
        /// <param name="domainFqdn">The domain FQDN.</param>
        /// <param name="sid">The SID.</param>
        /// <returns>An LDAP connection string.</returns>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="domainFqdn"/>is not a valid FQDN, or
        /// if <paramref name="sid"/> is not a valid SID.
        /// </exception>
        public static string ToLdapSidConnectionString(this string domainFqdn, string sid)
        {
            var fqdnResult = Fqdn.Create(domainFqdn);
            var sidResult  = AccountSid.Create(sid);

            if (fqdnResult.IsFailure)
            {
                throw new ArgumentException(fqdnResult.Error, nameof(domainFqdn));
            }

            if (sidResult.IsFailure)
            {
                throw new ArgumentException(sidResult.Error, nameof(sid));
            }

            return(fqdnResult.Value.ToLdapSidConnectionString(sidResult.Value));
        }