public void AddLdapIdentitySource(
            string domainName,
            string domainAlias,
            string friendlyName,
            string primaryUrl,
            string failoverUrl,
            string baseDNUsers,
            string baseDNGroups,
            string authenticationUserName,
            string authenticationPassword,
            string serverType,
            X509Certificate2[] ldapCertificates)
        {
            string authenticationType          = "password";
            var    authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            var adminLdapIdentitySourceDetails = new SsoAdminLdapIdentitySourceDetails {
                friendlyName = friendlyName,
                primaryUrl   = primaryUrl,
                failoverUrl  = failoverUrl,
                userBaseDn   = baseDNUsers,
                groupBaseDn  = baseDNGroups
            };

            if (ldapCertificates != null && ldapCertificates.Length > 0)
            {
                var certificates = new List <string>();
                foreach (var ldapCert in ldapCertificates)
                {
                    certificates.Add(Convert.ToBase64String(ldapCert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks));
                }

                if (certificates.Count > 0)
                {
                    adminLdapIdentitySourceDetails.certificates = certificates.ToArray();
                }
            }

            try {
                authorizedInvocationContext.
                InvokeOperation(() =>
                                _ssoAdminBindingClient.RegisterLdapAsync(
                                    new ManagedObjectReference {
                    type  = "SsoAdminIdentitySourceManagementService",
                    Value = "identitySourceManagementService"
                },
                                    serverType,
                                    domainName,
                                    domainAlias,
                                    adminLdapIdentitySourceDetails,
                                    authenticationType,
                                    new SsoAdminIdentitySourceManagementServiceAuthenticationCredentials {
                    username = authenticationUserName,
                    password = authenticationPassword
                })).Wait();
            } catch (AggregateException e) {
                throw e.InnerException;
            }
        }