/// <summary>
        /// RefreshData method implementation
        /// </summary>
        internal void RefreshData()
        {
            ComponentResourceManager resources = new ComponentResourceManager(typeof(ProvidersViewControl));

            this.label1.Text = resources.GetString("label1.Text");
            this.label2.Text = resources.GetString("label2.Text");
            this.label3.Text = resources.GetString("label3.Text");

            this.SuspendLayout();
            this.Cursor = Cursors.WaitCursor;
            try
            {
                for (int j = this.tableLayoutPanel.Controls.Count - 1; j >= 0; j--)
                {
                    Control ctrl = this.tableLayoutPanel.Controls[j];
                    if (ctrl is MFAProvidersControl)
                    {
                        this.tableLayoutPanel.Controls.RemoveAt(j);
                    }
                    if (ctrl is MFAProvidersValidationControl)
                    {
                        this.tableLayoutPanel.Controls.RemoveAt(j);
                    }
                }
                int i = 2;
                IExternalProvider totp = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);
                if (totp != null)
                {
                    this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, totp), 0, i);
                    i++;
                }

                IExternalProvider email = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);
                if (email != null)
                {
                    this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, email), 0, i);
                    i++;
                }
                IExternalProvider phone = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);
                if (phone != null)
                {
                    this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, phone), 0, i);
                    i++;
                }
                IExternalProvider azure = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Azure);
                if (azure != null)
                {
                    this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, azure), 0, i);
                    i++;
                }
                this.tableLayoutPanel.Controls.Add(new MFAProvidersValidationControl(this, this.SnapIn), 0, i);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.ResumeLayout();
            }
        }
Beispiel #2
0
        /// <summary>
        /// CkeckUpdate method implementation
        /// </summary>
        public virtual void CheckUpdates(PSHost host)
        {
            IExternalProvider prov = RuntimeAuthProvider.GetProviderInstance(Kind);

            if (prov != null)
            {
                if ((!prov.AllowDisable) && (!this.Enabled))
                {
                    throw new Exception("This Provider cannot be Disabled !");
                }
                if ((!prov.AllowEnrollment) && (this.EnrollWizard))
                {
                    throw new Exception("This Provider do not support Wizards !");
                }
            }
        }
 /// <summary>
 /// OnInitialize method
 /// </summary>
 protected virtual void OnInitialize()
 {
     this.SuspendLayout();
     try
     {
         int i = 2;
         IExternalProvider totp = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);
         if (totp != null)
         {
             this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, totp), 0, i);
             i++;
         }
         IExternalProvider email = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);
         if (email != null)
         {
             this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, email), 0, i);
             i++;
         }
         IExternalProvider phone = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);
         if (phone != null)
         {
             this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, phone), 0, i);
             i++;
         }
         IExternalProvider azure = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Azure);
         if (azure != null)
         {
             this.tableLayoutPanel.Controls.Add(new MFAProvidersControl(this, this.SnapIn, azure), 0, i);
             i++;
         }
         this.tableLayoutPanel.Controls.Add(new MFAProvidersValidationControl(this, this.SnapIn), 0, i);
     }
     finally
     {
         this.ResumeLayout(true);
     }
 }
        /// <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>
        /// BuildNodes method
        /// </summary>
        private void BuildNodes(bool doall = true)
        {
            if (doall)
            {
                this.RootNode = new RootScopeNode();
                FormViewDescription fvr = new FormViewDescription();
                fvr.DisplayName = "MFA Platform";
                fvr.ControlType = typeof(RootViewControl);
                fvr.ViewType    = typeof(RootFormView);
                this.RootNode.ViewDescriptions.Add(fvr);
                this.RootNode.ViewDescriptions.DefaultIndex = 0;

                if (IsPrimary)
                {
                    // Service Node
                    this.ServiceNode = new ServiceScopeNode();
                    FormViewDescription fvc = new FormViewDescription();
                    fvc.DisplayName = "MFA Platform Service";
                    fvc.ControlType = typeof(ServiceViewControl);
                    fvc.ViewType    = typeof(ServiceFormView);
                    this.ServiceNode.ViewDescriptions.Add(fvc);
                    this.ServiceNode.ViewDescriptions.DefaultIndex = 0;

                    // General Scope
                    this.ServiceGeneralNode = new ServiceGeneralScopeNode();
                    FormViewDescription fvs = new FormViewDescription();
                    fvs.DisplayName = "MFA Platform General Properties";
                    fvs.ControlType = typeof(GeneralViewControl);
                    fvs.ViewType    = typeof(GeneralFormView);
                    this.ServiceGeneralNode.ViewDescriptions.Add(fvs);
                    this.ServiceGeneralNode.ViewDescriptions.DefaultIndex = 0;

                    // ADDS Scope
                    this.ServiceADDSNode = new ServiceADDSScopeNode();
                    FormViewDescription fadds = new FormViewDescription();
                    fadds.DisplayName = "MFA Platform Active Directory Properties";
                    fadds.ControlType = typeof(ADDSViewControl);
                    fadds.ViewType    = typeof(ServiceADDSFormView);
                    this.ServiceADDSNode.ViewDescriptions.Add(fadds);
                    this.ServiceADDSNode.ViewDescriptions.DefaultIndex = 0;

                    // SQL Scope
                    this.ServiceSQLNode = new ServiceSQLScopeNode();
                    FormViewDescription fsql = new FormViewDescription();
                    fsql.DisplayName = "MFA Platform SQL Server Properties";
                    fsql.ControlType = typeof(SQLViewControl);
                    fsql.ViewType    = typeof(ServiceSQLFormView);
                    this.ServiceSQLNode.ViewDescriptions.Add(fsql);
                    this.ServiceSQLNode.ViewDescriptions.DefaultIndex = 0;

                    // Security Scope
                    this.ServiceSecurityNode = new ServiceSecurityRootScopeNode();
                    FormViewDescription fsec = new FormViewDescription();
                    fsec.DisplayName = "Security Features";
                    fsec.ControlType = typeof(ServiceSecurityRootViewControl);
                    fsec.ViewType    = typeof(ServiceSecurityRootFormView);
                    this.ServiceSecurityNode.ViewDescriptions.Add(fsec);
                    this.ServiceSecurityNode.ViewDescriptions.DefaultIndex = 0;

                    // RNG
                    this.ServiceRNGNode = new ServiceSecurityRNGScopeNode();
                    FormViewDescription frng = new FormViewDescription();
                    frng.DisplayName = "RGN Ramdom Number Generator";
                    frng.ControlType = typeof(ServiceSecurityRNGViewControl);
                    frng.ViewType    = typeof(ServiceSecurityRNGFormView);
                    this.ServiceRNGNode.ViewDescriptions.Add(frng);
                    this.ServiceRNGNode.ViewDescriptions.DefaultIndex = 0;

                    // RSA
                    this.ServiceRSANode = new ServiceSecurityRSAScopeNode();
                    FormViewDescription frsa = new FormViewDescription();
                    frsa.DisplayName = "RSA Key Generator";
                    frsa.ControlType = typeof(ServiceSecurityRSAViewControl);
                    frsa.ViewType    = typeof(ServiceSecurityRSAFormView);
                    this.ServiceRSANode.ViewDescriptions.Add(frsa);
                    this.ServiceRSANode.ViewDescriptions.DefaultIndex = 0;

                    // RSA CUST
                    this.ServiceRSAXNode = new ServiceSecurityRSAXScopeNode();
                    FormViewDescription frsax = new FormViewDescription();
                    frsax.DisplayName = "RSA Extended Key Generator";
                    frsax.ControlType = typeof(ServiceSecurityRSAXViewControl);
                    frsax.ViewType    = typeof(ServiceSecurityRSAXFormView);
                    this.ServiceRSAXNode.ViewDescriptions.Add(frsax);
                    this.ServiceRSAXNode.ViewDescriptions.DefaultIndex = 0;

                    // Providers Scope
                    this.ServiceProvidersNode = new ServiceProvidersScopeNode();
                    FormViewDescription fprov = new FormViewDescription();
                    fprov.DisplayName = "MFA Providers";
                    fprov.ControlType = typeof(ProvidersViewControl);
                    fprov.ViewType    = typeof(ServiceProvidersFormView);
                    this.ServiceProvidersNode.ViewDescriptions.Add(fprov);
                    this.ServiceProvidersNode.ViewDescriptions.DefaultIndex = 0;

                    ManagementService.EnsureService();
                    RuntimeAuthProvider.LoadProviders(ManagementService.Config);

                    IExternalProvider prv0 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);
                    if (prv0 != null)
                    {
                        // TOTP Scope
                        this.ServiceTOTPNode = new ServiceSecurityScopeNode();
                        FormViewDescription ftotp = new FormViewDescription();
                        ftotp.DisplayName = "MFA Platform TOTP Properties";
                        ftotp.ControlType = typeof(ServiceSecurityViewControl);
                        ftotp.ViewType    = typeof(ServiceSecurityFormView);
                        this.ServiceTOTPNode.ViewDescriptions.Add(ftotp);
                        this.ServiceTOTPNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv1 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);
                    if (prv1 != null)
                    {
                        // SMTP Scope
                        this.ServiceSMTPNode = new ServiceSMTPScopeNode();
                        FormViewDescription fsmtp = new FormViewDescription();
                        fsmtp.DisplayName = "MFA Platform SMTP Properties";
                        fsmtp.ControlType = typeof(SMTPViewControl);
                        fsmtp.ViewType    = typeof(ServiceSMTPFormView);
                        this.ServiceSMTPNode.ViewDescriptions.Add(fsmtp);
                        this.ServiceSMTPNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv2 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);
                    if (prv2 != null)
                    {
                        // SMS Scope
                        this.ServiceSMSNode = new ServicePhoneScopeNode();
                        FormViewDescription fsms = new FormViewDescription();
                        fsms.DisplayName = "MFA Platform SMS Properties";
                        fsms.ControlType = typeof(SMSViewControl);
                        fsms.ViewType    = typeof(ServiceSMSFormView);
                        this.ServiceSMSNode.ViewDescriptions.Add(fsms);
                        this.ServiceSMSNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv3 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Azure);
                    if (prv3 != null)
                    {
                        // Azure Scope
                        this.ServiceAzureNode = new ServiceAzureScopeNode();
                        FormViewDescription faz = new FormViewDescription();
                        faz.DisplayName = "MFA Platform SMS Properties";
                        faz.ControlType = typeof(AzureViewControl);
                        faz.ViewType    = typeof(ServiceAzureFormView);
                        this.ServiceAzureNode.ViewDescriptions.Add(faz);
                        this.ServiceAzureNode.ViewDescriptions.DefaultIndex = 0;
                    }
                }

                // Users Scope
                this.UsersNode = new UsersScopeNode();
                FormViewDescription fvu = new FormViewDescription();
                fvu.DisplayName = "MFA Platform Users";
                fvu.ControlType = typeof(UsersListView);
                fvu.ViewType    = typeof(UsersFormView);
                this.UsersNode.ViewDescriptions.Add(fvu);
                this.UsersNode.ViewDescriptions.DefaultIndex = 0;

                if (IsPrimary)
                {
                    this.RootNode.Children.Add(this.ServiceNode);
                    this.RootNode.Children.Add(this.ServiceGeneralNode);
                    this.RootNode.Children.Add(this.ServiceADDSNode);
                    this.RootNode.Children.Add(this.ServiceSQLNode);

                    this.RootNode.Children.Add(this.ServiceSecurityNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceRNGNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceRSANode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceRSAXNode);

                    this.RootNode.Children.Add(this.ServiceProvidersNode);
                    if (this.ServiceTOTPNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceTOTPNode);
                    }
                    if (this.ServiceSMTPNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceSMTPNode);
                    }
                    if (this.ServiceSMSNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceSMSNode);
                    }
                    if (this.ServiceAzureNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceAzureNode);
                    }
                }
                this.RootNode.Children.Add(this.UsersNode);

                this.IsModified = true;
                this.SmallImages.Add(Neos.IdentityServer.Console.Resources.Neos_IdentityServer_Console_Snapin.folder16, Color.Black);
                this.LargeImages.Add(Neos.IdentityServer.Console.Resources.Neos_IdentityServer_Console_Snapin.folder32, Color.Black);
            }
            else
            {
                RefreshUI();
            }
        }
 /// <summary>
 /// GetProviderInstance method implementation
 /// </summary>
 public static IExternalProvider GetProviderInstance(PreferredMethod method)
 {
     return(RuntimeAuthProvider.GetProviderInstance(method));
 }
Beispiel #7
0
        /// <summary>
        /// BuildNodes method
        /// </summary>
        private void BuildNodes(bool doall = true)
        {
            if (doall)
            {
                this.RootNode = new RootScopeNode();
                FormViewDescription fvr = new FormViewDescription();
                fvr.DisplayName = "MFA Platform";
                fvr.ControlType = typeof(RootViewControl);
                fvr.ViewType    = typeof(RootFormView);
                this.RootNode.ViewDescriptions.Add(fvr);
                this.RootNode.ViewDescriptions.DefaultIndex = 0;

                if (IsPrimary)
                {
                    // Service Node
                    this.ServiceNode = new ServiceScopeNode();
                    FormViewDescription fvc = new FormViewDescription();
                    fvc.DisplayName = "MFA Platform Service";
                    fvc.ControlType = typeof(ServiceViewControl);
                    fvc.ViewType    = typeof(ServiceFormView);
                    this.ServiceNode.ViewDescriptions.Add(fvc);
                    this.ServiceNode.ViewDescriptions.DefaultIndex = 0;

                    // General Scope
                    this.ServiceGeneralNode = new ServiceGeneralScopeNode();
                    FormViewDescription fvs = new FormViewDescription();
                    fvs.DisplayName = "MFA Platform General Properties";
                    fvs.ControlType = typeof(GeneralViewControl);
                    fvs.ViewType    = typeof(GeneralFormView);
                    this.ServiceGeneralNode.ViewDescriptions.Add(fvs);
                    this.ServiceGeneralNode.ViewDescriptions.DefaultIndex = 0;

                    // Storage
                    this.ServiceStorageNode = new ServiceStorageScopeNode();
                    FormViewDescription fstore = new FormViewDescription();
                    fstore.DisplayName = "MFA Platform Storage Properties";
                    fstore.ControlType = typeof(StorageViewControl);
                    fstore.ViewType    = typeof(ServiceStoreFormView);
                    this.ServiceStorageNode.ViewDescriptions.Add(fstore);
                    this.ServiceStorageNode.ViewDescriptions.DefaultIndex = 0;

                    // ADDS Scope
                    this.ServiceADDSNode = new ServiceADDSScopeNode();
                    FormViewDescription fadds = new FormViewDescription();
                    fadds.DisplayName = "MFA Platform Active Directory Properties";
                    fadds.ControlType = typeof(ADDSViewControl);
                    fadds.ViewType    = typeof(ServiceADDSFormView);
                    this.ServiceADDSNode.ViewDescriptions.Add(fadds);
                    this.ServiceADDSNode.ViewDescriptions.DefaultIndex = 0;

                    // SQL Scope
                    this.ServiceSQLNode = new ServiceSQLScopeNode();
                    FormViewDescription fsql = new FormViewDescription();
                    fsql.DisplayName = "MFA Platform SQL Server Properties";
                    fsql.ControlType = typeof(SQLViewControl);
                    fsql.ViewType    = typeof(ServiceSQLFormView);
                    this.ServiceSQLNode.ViewDescriptions.Add(fsql);
                    this.ServiceSQLNode.ViewDescriptions.DefaultIndex = 0;

                    // Custom Storage Scope
                    this.ServiceCustomStorageNode = new ServiceCustomStorageScopeNode();
                    FormViewDescription cust = new FormViewDescription();
                    cust.DisplayName = "MFA Custom Storage Properties";
                    cust.ControlType = typeof(CustomStoreViewControl);
                    cust.ViewType    = typeof(ServiceCustomStoreFormView);
                    this.ServiceCustomStorageNode.ViewDescriptions.Add(cust);
                    this.ServiceCustomStorageNode.ViewDescriptions.DefaultIndex = 0;

                    // Security Scope
                    this.ServiceSecurityNode = new ServiceSecurityRootScopeNode();
                    FormViewDescription fsec = new FormViewDescription();
                    fsec.DisplayName = "Security Features";
                    fsec.ControlType = typeof(ServiceSecurityRootViewControl);
                    fsec.ViewType    = typeof(ServiceSecurityRootFormView);
                    this.ServiceSecurityNode.ViewDescriptions.Add(fsec);
                    this.ServiceSecurityNode.ViewDescriptions.DefaultIndex = 0;

                    // RNG
                    this.ServiceRNGNode = new ServiceSecurityRNGScopeNode();
                    FormViewDescription frng = new FormViewDescription();
                    frng.DisplayName = "Encoded Keys RGN ";
                    frng.ControlType = typeof(ServiceSecurityRNGViewControl);
                    frng.ViewType    = typeof(ServiceSecurityRNGFormView);
                    this.ServiceRNGNode.ViewDescriptions.Add(frng);
                    this.ServiceRNGNode.ViewDescriptions.DefaultIndex = 0;

                    // AES
                    this.ServiceAESNode = new ServiceSecurityAESScopeNode();
                    FormViewDescription faes = new FormViewDescription();
                    faes.DisplayName = "Symmetric Keys AES";
                    faes.ControlType = typeof(ServiceSecurityAESViewControl);
                    faes.ViewType    = typeof(ServiceSecurityAESFormView);
                    this.ServiceAESNode.ViewDescriptions.Add(faes);
                    this.ServiceAESNode.ViewDescriptions.DefaultIndex = 0;

                    // RSA
                    this.ServiceRSANode = new ServiceSecurityRSAScopeNode();
                    FormViewDescription frsa = new FormViewDescription();
                    frsa.DisplayName = "Asymmetric Keys RSA ";
                    frsa.ControlType = typeof(ServiceSecurityRSAViewControl);
                    frsa.ViewType    = typeof(ServiceSecurityRSAFormView);
                    this.ServiceRSANode.ViewDescriptions.Add(frsa);
                    this.ServiceRSANode.ViewDescriptions.DefaultIndex = 0;

                    // Custom
                    this.ServiceCustomSecurityNode = new ServiceCustomSecurityScopeNode();
                    FormViewDescription fcust = new FormViewDescription();
                    fcust.DisplayName = "Custom Keys";
                    fcust.ControlType = typeof(SecurityCustomViewControl);
                    fcust.ViewType    = typeof(ServiceSecurityCustomFormView);
                    this.ServiceCustomSecurityNode.ViewDescriptions.Add(fcust);
                    this.ServiceCustomSecurityNode.ViewDescriptions.DefaultIndex = 0;

                    // WebAuthN
                    this.ServiceWebAuthNNode = new ServiceSecurityWebAuthNScopeNode();
                    FormViewDescription frweb = new FormViewDescription();
                    frweb.DisplayName = "WebAuthN Credentials";
                    frweb.ControlType = typeof(ServiceSecurityWebAuthNViewControl);
                    frweb.ViewType    = typeof(ServiceSecurityWebAuthNFormView);
                    this.ServiceWebAuthNNode.ViewDescriptions.Add(frweb);
                    this.ServiceWebAuthNNode.ViewDescriptions.DefaultIndex = 0;

                    // Providers Scope
                    this.ServiceProvidersNode = new ServiceProvidersScopeNode();
                    FormViewDescription fprov = new FormViewDescription();
                    fprov.DisplayName = "MFA Providers";
                    fprov.ControlType = typeof(ProvidersViewControl);
                    fprov.ViewType    = typeof(ServiceProvidersFormView);
                    this.ServiceProvidersNode.ViewDescriptions.Add(fprov);
                    this.ServiceProvidersNode.ViewDescriptions.DefaultIndex = 0;

                    ManagementService.EnsureService();
                    RuntimeAuthProvider.LoadProviders(ManagementService.Config);

                    IExternalProvider prv0 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Code);
                    if (prv0 != null)
                    {
                        // TOTP Scope
                        this.ServiceTOTPNode = new ServiceTOTPScopeNode();
                        FormViewDescription ftotp = new FormViewDescription();
                        ftotp.DisplayName = "MFA Platform TOTP Properties";
                        ftotp.ControlType = typeof(ServiceTOTPViewControl);
                        ftotp.ViewType    = typeof(ServiceTOTPFormView);
                        this.ServiceTOTPNode.ViewDescriptions.Add(ftotp);
                        this.ServiceTOTPNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv4 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Biometrics);
                    if (prv4 != null)
                    {
                        // Biometrics Scope
                        this.ServiceBiometricsNode = new ServiceBiometricsScopeNode();
                        FormViewDescription fbio = new FormViewDescription();
                        fbio.DisplayName = "MFA Platform Biometrics Properties";
                        fbio.ControlType = typeof(ServiceBiometricsViewControl);
                        fbio.ViewType    = typeof(ServiceBiometricsFormView);
                        this.ServiceBiometricsNode.ViewDescriptions.Add(fbio);
                        this.ServiceBiometricsNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv1 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Email);
                    if (prv1 != null)
                    {
                        // SMTP Scope
                        this.ServiceSMTPNode = new ServiceSMTPScopeNode();
                        FormViewDescription fsmtp = new FormViewDescription();
                        fsmtp.DisplayName = "MFA Platform SMTP Properties";
                        fsmtp.ControlType = typeof(SMTPViewControl);
                        fsmtp.ViewType    = typeof(ServiceSMTPFormView);
                        this.ServiceSMTPNode.ViewDescriptions.Add(fsmtp);
                        this.ServiceSMTPNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv2 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.External);
                    if (prv2 != null)
                    {
                        // SMS Scope
                        this.ServiceSMSNode = new ServicePhoneScopeNode();
                        FormViewDescription fsms = new FormViewDescription();
                        fsms.DisplayName = "MFA Platform SMS Properties";
                        fsms.ControlType = typeof(SMSViewControl);
                        fsms.ViewType    = typeof(ServiceSMSFormView);
                        this.ServiceSMSNode.ViewDescriptions.Add(fsms);
                        this.ServiceSMSNode.ViewDescriptions.DefaultIndex = 0;
                    }

                    IExternalProvider prv3 = RuntimeAuthProvider.GetProviderInstance(PreferredMethod.Azure);
                    if (prv3 != null)
                    {
                        // Azure Scope
                        this.ServiceAzureNode = new ServiceAzureScopeNode();
                        FormViewDescription faz = new FormViewDescription();
                        faz.DisplayName = "MFA Platform SMS Properties";
                        faz.ControlType = typeof(AzureViewControl);
                        faz.ViewType    = typeof(ServiceAzureFormView);
                        this.ServiceAzureNode.ViewDescriptions.Add(faz);
                        this.ServiceAzureNode.ViewDescriptions.DefaultIndex = 0;
                    }
                }

                // Users Scope
                this.UsersNode = new UsersScopeNode();
                FormViewDescription fvu = new FormViewDescription();
                fvu.DisplayName = "MFA Platform Users";
                fvu.ControlType = typeof(UsersListView);
                fvu.ViewType    = typeof(UsersFormView);
                this.UsersNode.ViewDescriptions.Add(fvu);
                this.UsersNode.ViewDescriptions.DefaultIndex = 0;


                if (IsPrimary)
                {
                    this.RootNode.Children.Add(this.ServiceNode);
                    this.RootNode.Children.Add(this.ServiceGeneralNode);

                    this.RootNode.Children.Add(this.ServiceSecurityNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceRNGNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceAESNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceRSANode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceWebAuthNNode);
                    this.ServiceSecurityNode.Children.Add(this.ServiceCustomSecurityNode);

                    this.RootNode.Children.Add(this.ServiceStorageNode);
                    this.ServiceStorageNode.Children.Add(this.ServiceADDSNode);
                    this.ServiceStorageNode.Children.Add(this.ServiceSQLNode);
                    this.ServiceStorageNode.Children.Add(this.ServiceCustomStorageNode);

                    this.RootNode.Children.Add(this.ServiceProvidersNode);
                    if (this.ServiceTOTPNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceTOTPNode);
                    }
                    if (this.ServiceBiometricsNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceBiometricsNode);
                    }
                    if (this.ServiceSMTPNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceSMTPNode);
                    }
                    if (this.ServiceSMSNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceSMSNode);
                    }
                    if (this.ServiceAzureNode != null)
                    {
                        this.ServiceProvidersNode.Children.Add(this.ServiceAzureNode);
                    }
                }
                this.RootNode.Children.Add(this.UsersNode);

                this.IsModified = true;
                this.SmallImages.Add(Neos.IdentityServer.Console.Resources.Neos_IdentityServer_Console_Snapin.folder16, Color.Black);
                this.LargeImages.Add(Neos.IdentityServer.Console.Resources.Neos_IdentityServer_Console_Snapin.folder32, Color.Black);
            }
            else
            {
                RefreshUI();
            }
        }