/// <summary>
 /// Adds the new entry in the listbox if it is not exists
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor();
     if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
     {
         if (_octStringAttrForm.sOctextStringAttrValue != "")
         {
             ListViewItem lviArr = null;
             string[] values = { _octStringAttrForm.sOctextStringAttrValue };
             lviArr = new ListViewItem(values);
             this.listViewAttrValues.Items.Add(lviArr);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Adds the new entry in the listbox if it is not exists
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor();

            if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
            {
                if (_octStringAttrForm.sOctextStringAttrValue != "")
                {
                    ListViewItem lviArr = null;
                    string[]     values = { _octStringAttrForm.sOctextStringAttrValue };
                    lviArr = new ListViewItem(values);
                    this.listViewAttrValues.Items.Add(lviArr);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Allows us to edit the selected listbox item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (listViewAttrValues.SelectedIndices.Count == 0)
            {
                return;
            }

            string sListBoxValue = listViewAttrValues.Items[listViewAttrValues.SelectedItems[0].Index].Text.ToString();

            OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor(lvSelectedItem.SubItems[0].Text, sListBoxValue);

            if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
            {
                if (_octStringAttrForm.sOctextStringAttrValue != "")
                {
                    listViewAttrValues.Items.RemoveAt(listViewAttrValues.SelectedItems[0].Index);
                    listViewAttrValues.Items.Add(_octStringAttrForm.sOctextStringAttrValue);
                }
                btnEdit.Enabled = false;
            }
        }
Example #4
0
    /// <summary>
    /// Shows the specified editor control based on the selected attribute syntax from the listview.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void btnEdit_Click(object sender, EventArgs e)
    {
        if (lvAttrs.SelectedItems.Count == 0)
        {
            return;
        }
        SchemaType schemaType = null;
        ListViewItem selectedItem = lvAttrs.SelectedItems[0];

        if (selectedItem.Text.Trim().Equals("objectGUID") || selectedItem.Text.Trim().Equals("objectSid"))
        {
            OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor(selectedItem);
            if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
            {
                if (_octStringAttrForm.sOctextStringAttrValue != "")
                {
                    lvAttrs.SelectedItems[0].SubItems[2].Text = _octStringAttrForm.sOctextStringAttrValue;
                    lvAttrs.SelectedItems[0].SubItems[2].Tag = _octStringAttrForm.origsOctextStringAttrValue;
                    lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                    if (!_modifiedPageObject.IsListItemChanged)
                    {
                        _modifiedPageObject.IsListItemChanged = true;
                    }
                }
            }
            return;
        }
        else
        {
            if (selectedItem.Tag != null)
            {
                schemaType = selectedItem.Tag as SchemaType;
            }
            if (schemaType != null)
            {
                switch (schemaType.DataType)
                {
                    case ADSType.ADSTYPE_INTEGER:
                    case ADSType.ADSTYPE_LARGE_INTEGER:
                    case ADSType.ADSTYPE_NUMERIC_STRING:
                    if (schemaType.IsSingleValued)
                    {
                        IntegerAttributeEditor _IntForm = new IntegerAttributeEditor(selectedItem);
                        if (schemaType.DataType == ADSType.ADSTYPE_LARGE_INTEGER)
                        {
                            _IntForm.Text = "Large Integer Attribute Editor";
                        }
                        else
                        {
                            _IntForm.Text = "Integer Attribute Editor";
                        }
                        DialogResult dlg = _IntForm.ShowDialog(this);
                        if (dlg == DialogResult.OK)
                        {
                            if (_IntForm.IntAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _IntForm.IntAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _IntForm.OrigIntAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";

                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        MultiValuedStringEditor _mulvalstringForm = new MultiValuedStringEditor(selectedItem, true);
                        if (_mulvalstringForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_mulvalstringForm.sMultiValuedStringAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _mulvalstringForm.sMultiValuedStringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    break;
                    case ADSType.ADSTYPE_OCTET_STRING:

                    if (schemaType.IsSingleValued)
                    {
                        OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor(selectedItem);
                        if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_octStringAttrForm.sOctextStringAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _octStringAttrForm.sOctextStringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _octStringAttrForm.origsOctextStringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        MultiValuedOctetEditor _mulvaloctStringAttrForm = new MultiValuedOctetEditor(selectedItem);
                        if (_mulvaloctStringAttrForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_mulvaloctStringAttrForm.sMultiValuedOctetAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _mulvaloctStringAttrForm.sMultiValuedOctetAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _mulvaloctStringAttrForm.origsMultiValuedOctetAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    break;
                    case ADSType.ADSTYPE_CASE_IGNORE_STRING:
                    case ADSType.ADSTYPE_DN_WITH_BINARY:
                    case ADSType.ADSTYPE_DN_WITH_STRING:
                    case ADSType.ADSTYPE_CASE_EXACT_STRING:
                    case ADSType.ADSTYPE_DN_STRING:
                    case ADSType.ADSTYPE_PRINTABLE_STRING:
                    case ADSType.ADSTYPE_NT_SECURITY_DESCRIPTOR:
                    if (schemaType.IsSingleValued)
                    {
                        StringAttributeEditor _stringForm = new StringAttributeEditor(selectedItem);
                        if (_stringForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_stringForm.stringAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _stringForm.stringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _stringForm.origstringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        //this should be the place that "memberOf" attribute gets edited.
                        MultiValuedStringEditor _mulvalstringForm = new MultiValuedStringEditor(selectedItem, false);
                        if (_mulvalstringForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_mulvalstringForm.sMultiValuedStringAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _mulvalstringForm.sMultiValuedStringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _mulvalstringForm.origsMultiValuedStringAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    break;
                    case ADSType.ADSTYPE_UTC_TIME:
                    if (schemaType.IsSingleValued)
                    {
                        TimeAttributeEditor _timeForm = new TimeAttributeEditor(selectedItem);
                        if (_timeForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_timeForm.sDateAttrValue != "" && _timeForm.sTimeAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _timeForm.sDateAttrValue + " " + _timeForm.sTimeAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }

                        }
                    }
                    else
                    {
                        MultiValuedTimeEditor _MulTimeForm = new MultiValuedTimeEditor(selectedItem);
                        if (_MulTimeForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_MulTimeForm.sMultiValuedtimeAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _MulTimeForm.sMultiValuedtimeAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    break;
                    case ADSType.ADSTYPE_BOOLEAN:
                    if (schemaType.IsSingleValued)
                    {
                        BooleanAttributeEditor _booleanForm = new BooleanAttributeEditor(selectedItem);
                        if (_booleanForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_booleanForm.sBooleanAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _booleanForm.sBooleanAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        MultiValuedBooleanEditor _MulValueBooleanForm = new MultiValuedBooleanEditor(selectedItem);
                        if (_MulValueBooleanForm.ShowDialog(this) == DialogResult.OK)
                        {
                            if (_MulValueBooleanForm.sMultiValuedBooleanAttrValue != "")
                            {
                                lvAttrs.SelectedItems[0].SubItems[2].Text = _MulValueBooleanForm.sMultiValuedBooleanAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[2].Tag = _MulValueBooleanForm.origsMultiValuedBooleanAttrValue;
                                lvAttrs.SelectedItems[0].SubItems[4].Text = "true";
                                if (!_modifiedPageObject.IsListItemChanged)
                                {
                                    _modifiedPageObject.IsListItemChanged = true;
                                }
                            }
                        }
                    }

                    break;
                }
            }
        }
        UpdateApplyButton();
        lvAttrs.Focus();
    }
        /// <summary>
        /// Allows us to edit the selected listbox item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (listViewAttrValues.SelectedIndices.Count == 0)
                return;

            string sListBoxValue = listViewAttrValues.Items[listViewAttrValues.SelectedItems[0].Index].Text.ToString();

            OctetStringAttributeEditor _octStringAttrForm = new OctetStringAttributeEditor(lvSelectedItem.SubItems[0].Text, sListBoxValue);
            if (_octStringAttrForm.ShowDialog(this) == DialogResult.OK)
            {
                if (_octStringAttrForm.sOctextStringAttrValue != "")
                {
                    listViewAttrValues.Items.RemoveAt(listViewAttrValues.SelectedItems[0].Index);
                    listViewAttrValues.Items.Add(_octStringAttrForm.sOctextStringAttrValue);
                }
                btnEdit.Enabled = false;
            }
        }