コード例 #1
0
        /// <summary>
        /// CanApplyDataChanges method implementation
        /// </summary>
        private bool CanApplyDataChanges(MFAUser registration)
        {
            bool result = true;

            if (registration.IsApplied)
            {
                return(result);
            }
            IExternalProvider prov1 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);

            if (prov1 != null)
            {
                if ((prov1.Enabled) && (prov1.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.UPN))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDUSER,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                    else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN)))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDKEY,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(1);
                        result = false;
                    }
                }
            }
            IExternalProvider prov2 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);

            if (prov2 != null)
            {
                if ((prov2.Enabled) && (prov2.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.MailAddress))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDMAIL,
                            Buttons = MessageBoxButtons.YesNo,
                            Icon    = MessageBoxIcon.Warning
                        };
                        if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                            ParentSheet.SetActivePage(0);
                        }
                    }
                    else if (!MMCService.IsValidEmail(registration.MailAddress))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEINVALIDMAIL,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                }
            }
            IExternalProvider prov3 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);

            if (prov3 != null)
            {
                if ((prov3.Enabled) && (prov3.IsRequired))
                {
                    if (string.IsNullOrEmpty(registration.PhoneNumber))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEVALIDPHONE,
                            Buttons = MessageBoxButtons.YesNo,
                            Icon    = MessageBoxIcon.Warning
                        };
                        if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                            ParentSheet.SetActivePage(0);
                        }
                    }
                    else if (!MMCService.IsValidPhone(registration.PhoneNumber))
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters
                        {
                            Text    = res.PPAGEINVALIDPHONE,
                            Buttons = MessageBoxButtons.OK,
                            Icon    = MessageBoxIcon.Error
                        };
                        ParentSheet.ShowDialog(messageBoxParameters);
                        ParentSheet.SetActivePage(0);
                        result = false;
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// CanApplyDataChanges method implementation
        /// </summary>
        private bool CanApplyDataChanges(Registration registration)
        {
            bool result = false;

            if (registration.IsApplied)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(registration.UPN))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDUSER;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(MMCService.GetEncodedUserKey(registration.UPN)))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDKEY;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(1);
            }
            else if (string.IsNullOrEmpty(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDMAIL;
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!MMCService.IsValidEmail(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEINVALIDMAIL;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEVALIDPHONE;
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!MMCService.IsValidPhone(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = res.PPAGEINVALIDPHONE;
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else
            {
                result = true;
            }
            return(result);
        }
        /// <summary>
        /// CanApplyDataChanges method implementation
        /// </summary>
        private bool CanApplyDataChanges(MMCRegistration registration)
        {
            bool result = false;

            if (registration.IsApplied)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(registration.UPN))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "le nom de l'utilsateur ne peux être vide !";
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(KeysManager.ReadKey(registration.UPN)))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Une clé numérique valide est requise pour générer des codes TOTP permettant de valider votre identité !";
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(1);
            }
            else if (string.IsNullOrEmpty(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Une adresse de messagerie secondaire est requis pour recevoir les codes par e-mails !\rSouhaitez-vous continuer ?";
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!ManagementAdminService.IsValidEmail(registration.MailAddress))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Adresse de messagerie secondaire invalide !";
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else if (string.IsNullOrEmpty(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Un N° de téléphone est requis pour recevoir les codes par SMS !\r\rSouhaitez-vous continuer ?";
                messageBoxParameters.Buttons = MessageBoxButtons.YesNo;
                messageBoxParameters.Icon    = MessageBoxIcon.Warning;
                if (ParentSheet.ShowDialog(messageBoxParameters) == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    ParentSheet.SetActivePage(0);
                }
            }
            else if (!ManagementAdminService.IsValidPhone(registration.PhoneNumber))
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();
                messageBoxParameters.Text    = "Un N° de téléphone valide est requis pour recevoir les codes par SMS !";
                messageBoxParameters.Buttons = MessageBoxButtons.OK;
                messageBoxParameters.Icon    = MessageBoxIcon.Error;
                ParentSheet.ShowDialog(messageBoxParameters);
                ParentSheet.SetActivePage(0);
            }
            else
            {
                result = true;
            }
            return(result);
        }