Example #1
0
        public bool TestACConnection(ConnectionTestDTO test, out string info,
                                     out bool loginSameAsEmail)
        {
            if (test == null)
            {
                throw new ArgumentNullException(nameof(test));
            }

            loginSameAsEmail = false;
            //sharedTemplatesFolderScoId = null;
            info = string.Empty;

            if (string.IsNullOrWhiteSpace(test.password))
            {
                info = "Password is required";
                return(false);
            }

            if (!TestDomainFormat(test, out info))
            {
                return(false);
            }

            var provider = new AdobeConnectProvider(new ConnectionDetails(new Uri(test.domain)));
            var result   = provider.Login(new UserCredentials(test.login, test.password));

            if (!result.Success)
            {
                string error = FormatErrorFromAC(result);
                if (!string.IsNullOrWhiteSpace(error))
                {
                    info = error;
                }

                return(false);
            }

            CommonInfoResult commonInfo = provider.GetCommonInfo();

            if (!commonInfo.Success)
            {
                _logger.ErrorFormat("GetPasswordPolicies.GetUserInfo. AC error. {0}.", commonInfo.Status.GetErrorInfo());
                info = commonInfo.Status.GetErrorInfo();
                return(false);
            }

            if (commonInfo.CommonInfo.AccountId.HasValue)
            {
                FieldCollectionResult fields = provider.GetAclFields(commonInfo.CommonInfo.AccountId.Value);

                if (!fields.Success)
                {
                    _logger.ErrorFormat("GetPasswordPolicies.GetAclFields. AC error. {0}.", fields.Status.GetErrorInfo());
                    info = fields.Status.GetErrorInfo();
                    return(false);
                }

                //ScoContentCollectionResult sharedTemplates = provider.GetContentsByType("shared-meeting-templates");
                //if (!sharedTemplates.Success)
                //{
                //    logger.ErrorFormat("GetPasswordPolicies.get shared-meeting-templates. AC error. {0}.", sharedTemplates.Status.GetErrorInfo());
                //    info = sharedTemplates.Status.GetErrorInfo();
                //    return false;
                //}

                //sharedTemplatesFolderScoId = sharedTemplates.ScoId;

                string setting = GetField(fields, "login-same-as-email");
                loginSameAsEmail = string.IsNullOrEmpty(setting) || "YES".Equals(setting, StringComparison.OrdinalIgnoreCase);
                return(true);
            }

            _logger.Error("GetPasswordPolicies. Account is NULL. Check Adobe Connect account permissions. Admin account expected.");
            info = "Check Adobe Connect account permissions. Admin account expected.";
            return(false);
        }