示例#1
0
 /// <summary>
 /// UpdateNodes method implementation
 /// </summary>
 private void DeleteNodes(MMCRegistrationList registrations)
 {
     this.SelectionData.BeginUpdates();
     try
     {
         List <ResultNode> nds = new List <ResultNode>();
         RemoteAdminService.DeleteUser(registrations);
         foreach (MMCRegistration reg in registrations)
         {
             foreach (ResultNode res in this.ResultNodes)
             {
                 MMCRegistration xres = res;
                 if (reg.ID == xres.ID)
                 {
                     nds.Add(res);
                 }
             }
         }
         foreach (ResultNode res in nds)
         {
             ResultNodes.Remove(res);
         }
     }
     finally
     {
         this.SelectionData.EndUpdates();
     }
 }
示例#2
0
 /// <summary>
 /// UpdateResultNode method
 /// </summary>
 internal void UpdateResultNode(MMCRegistration registration, ResultNode resultnode)
 {
     if (registration == null)
     {
         return;
     }
     else
     {
         resultnode.SubItemDisplayNames.Clear();
         resultnode.DisplayName = registration.UPN;
         resultnode.SubItemDisplayNames.Add(registration.MailAddress);
         resultnode.SubItemDisplayNames.Add(registration.PhoneNumber);
         resultnode.SubItemDisplayNames.Add(registration.CreationDate.ToString());
         resultnode.SubItemDisplayNames.Add(registration.Enabled.ToString());
         resultnode.SubItemDisplayNames.Add(((int)registration.PreferredMethod).ToString());
         resultnode.SubItemDisplayNames.Add(registration.ID);
         resultnode.SubItemDisplayNames.Add(registration.SecretKey);
         if (registration.Enabled)
         {
             resultnode.ImageIndex = 1;
         }
         else
         {
             resultnode.ImageIndex = 2;
         }
     }
 }
        /// <summary>
        /// SetSharedUserData method implementation
        /// </summary>
        internal void SetSharedUserData(MMCRegistrationList registrations)
        {
            if (usersFormView == null)
            {
                return;
            }
            WritableSharedDataItem shareddata = usersFormView.SharedUserData.GetItem("@adfsmfa_useredit" + seed);

            if (shareddata == null)
            {
                return;
            }
            if (registrations == null)
            {
                registrations = (MMCRegistrationList)this.ParentSheet.SelectionObject;
                if (registrations == null)
                {
                    registrations = new MMCRegistrationList();
                    MMCRegistration reg = new MMCRegistration();
                    reg.Enabled = true;
                    registrations.Add(reg);
                }
            }
            shareddata.SetData(registrations);
        }
示例#4
0
        /// <summary>
        /// GetData method implmentation
        /// </summary>
        public MMCRegistrationList GetUserControlData(MMCRegistrationList lst)
        {
            MMCRegistration obj = ((MMCRegistrationList)lst)[0];

            ((MMCRegistration)obj).UPN             = this.UserName.Text;
            ((MMCRegistration)obj).MailAddress     = this.Email.Text;
            ((MMCRegistration)obj).PhoneNumber     = this.Phone.Text;
            ((MMCRegistration)obj).Enabled         = this.cbEnabled.Checked;
            ((MMCRegistration)obj).PreferredMethod = (RegistrationPreferredMethod)((int)this.CBMethod.SelectedValue);
            return(lst);
        }
示例#5
0
 /// <summary>
 /// SetData method implmentation
 /// </summary>
 public void SetUserControlData(MMCRegistrationList lst, bool disablesync)
 {
     SyncDisabled = disablesync;
     try
     {
         MMCRegistration obj = ((MMCRegistrationList)lst)[0];
         this.UserName.Text          = ((MMCRegistration)obj).UPN;
         this.Email.Text             = ((MMCRegistration)obj).MailAddress;
         this.Phone.Text             = ((MMCRegistration)obj).PhoneNumber;
         this.cbEnabled.Checked      = ((MMCRegistration)obj).Enabled;
         this.CBMethod.SelectedValue = (UsersPreferredMethod)(((MMCRegistration)obj).PreferredMethod);
     }
     finally
     {
         SyncDisabled = false;
     }
 }
示例#6
0
 /// <summary>
 /// UpdateRegistration method
 /// </summary>
 internal void UpdateRegistration(ResultNode resultnode, MMCRegistration registration)
 {
     if (resultnode == null)
     {
         return;
     }
     else
     {
         registration.UPN             = resultnode.DisplayName;
         registration.MailAddress     = resultnode.SubItemDisplayNames[0];
         registration.PhoneNumber     = resultnode.SubItemDisplayNames[1];
         registration.CreationDate    = Convert.ToDateTime(resultnode.SubItemDisplayNames[2]);
         registration.Enabled         = bool.Parse(resultnode.SubItemDisplayNames[3]);
         registration.PreferredMethod = (RegistrationPreferredMethod)Convert.ToInt32(resultnode.SubItemDisplayNames[4]);
         registration.ID        = resultnode.SubItemDisplayNames[5];
         registration.SecretKey = resultnode.SubItemDisplayNames[6];
     }
 }
示例#7
0
 /// <summary>
 /// When the Apply button is clicked, this method makes the changes take effect.
 /// </summary>
 /// <returns></returns>
 protected override bool OnApply()
 {
     if (this.Dirty)
     {
         if (userPropertiesControl.CanApplyChanges())
         {
             if (isnew)
             {
                 List <MMCRegistration> reg = new List <MMCRegistration>();
                 if (usersFormView.SelectionData.SharedData.GetItem("@adfsmfanewuser") == null)
                 {
                     reg.Add(new MMCRegistration());
                     userPropertiesControl.GetUserControlData(reg);
                     WritableSharedDataItem sh = new WritableSharedDataItem("@adfsmfanewuser", false);
                     sh.SetData(reg[0]);
                     usersFormView.SelectionData.SharedData.Add(sh);
                 }
                 else if (usersFormView != null)
                 {
                     WritableSharedDataItem sh  = usersFormView.SelectionData.SharedData.GetItem("@adfsmfanewuser");
                     MMCRegistration        res = sh.GetData();
                     reg.Add(res);
                     usersFormView.SelectionData.SharedData.Remove("@adfsmfanewuser");
                     userPropertiesControl.GetUserControlData(reg);
                     usersFormView.AddUserStoreData(reg);
                 }
             }
             else
             {
                 userPropertiesControl.GetUserControlData(this.ParentSheet.SelectionObject);
                 if (usersFormView != null)
                 {
                     usersFormView.SetUserStoreData(this.ParentSheet.SelectionObject);
                 }
             }
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
        /// <summary>
        /// SetUserControlData method implmentation
        /// </summary>
        public void SetUserControlData(MMCRegistrationList lst, bool disablesync)
        {
            SyncDisabled = disablesync;
            try
            {
                MMCRegistration obj = ((MMCRegistrationList)lst)[0];
                _secretkey = KeysManager.EncodedKey(((MMCRegistration)obj).UPN);
                _upn       = ((MMCRegistration)obj).UPN;
                _email     = ((MMCRegistration)obj).MailAddress;

                if (string.IsNullOrEmpty(_email))
                {
                    this.EmailPrompt.Text = "Adresse email : ";
                    _emailnotset          = true;
                }
                else
                {
                    this.EmailPrompt.Text = string.Format("Adresse email : {0}", _email);
                    _emailnotset          = false;
                }
                if (!string.IsNullOrEmpty(_secretkey))
                {
                    this.DisplayKey.Text = _secretkey;
                    if (!string.IsNullOrEmpty(_upn))
                    {
                        this.qrCodeGraphic.Text = ManagementAdminService.GetQRCodeValue(_upn, this.DisplayKey.Text);
                    }
                    else
                    {
                        this.qrCodeGraphic.Text = string.Empty;
                    }
                }
                else
                {
                    userPropertyPage.Dirty = true;
                }
                UpdateControlsEnabled();
            }
            finally
            {
                SyncDisabled = false;
            }
        }
        /// <summary>
        /// GetSelectedUsers method implementation
        /// </summary>
        internal MMCRegistrationList GetSelectedUsers()
        {
            MMCRegistrationList result = new MMCRegistrationList();

            foreach (DataGridViewRow row in GridView.SelectedRows)
            {
                MMCRegistration reg = new MMCRegistration();
                reg.ID = GridView.Rows[row.Index].Cells[1].Value.ToString();
                if (reg.ID != Guid.Empty.ToString())
                {
                    reg.UPN             = GridView.Rows[row.Index].Cells[2].Value.ToString();
                    reg.MailAddress     = GridView.Rows[row.Index].Cells[3].Value.ToString();
                    reg.PhoneNumber     = GridView.Rows[row.Index].Cells[4].Value.ToString();
                    reg.CreationDate    = Convert.ToDateTime(GridView.Rows[row.Index].Cells[5].Value);
                    reg.PreferredMethod = (RegistrationPreferredMethod)Enum.Parse(typeof(RegistrationPreferredMethod), GridView.Rows[row.Index].Cells[6].Value.ToString());
                    reg.Enabled         = (bool)bool.Parse(GridView.Rows[row.Index].Cells[7].Value.ToString());
                    result.Add(reg);
                }
            }
            return(result);
        }
        /// <summary>
        /// GetUserControlData method implmentation
        /// </summary>
        public MMCRegistrationList GetUserControlData(MMCRegistrationList lst)
        {
            MMCRegistration obj = lst[0];

            return(lst);
        }
        /// <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);
        }