コード例 #1
0
    public ADEditPage(MPContainer parentDlg)
    {
        pageID = "EditProperitiesAdvanced";
        InitializeComponent();

        // Create an instance of a ListView column sorter and assign it
        // to the ListView control.
        lvwColumnSorter = new ListViewColumnSorter();
        this.lvAttrs.ListViewItemSorter = lvwColumnSorter;

        SetPageTitle("Advanced");
        _modifiedPageObject = new ADEditPageObject();
        _EditPageObject = new EditPageObject(lvAttrs);
        _parentDlg = parentDlg;
    }
コード例 #2
0
    /// <summary>
    /// Method to get all attributes to the specified AD Object.
    /// </summary>
    /// <param name="AddNotset"></param>
    /// <param name="_modifiedPageObject"></param>
    private void FillAttributeList(bool AddNotset, out ADEditPageObject _modifiedPageObject)
    {
        _modifiedPageObject = new ADEditPageObject();
        lvAttrs.Items.Clear();

        if (ldapEntries == null ||
            ldapEntries.Count == 0 ||
            allowedAttributes == null)
        {
            return;
        }

        LdapEntry ldapNextEntry = ldapEntries[0];

        string[] attrsFullList = new string[allowedAttributes.Count];

        allowedAttributes.CopyTo(attrsFullList);

        attributeList = new List<ListViewItem>();

        foreach (string attr in attrsFullList)
        {
            string sValue = "";
            string sAttrType = "Optional";


            foreach (string mandatoryAttribute in MandatoryAttributes)
            {
                if (String.Equals(mandatoryAttribute, attr, StringComparison.InvariantCultureIgnoreCase))
                {
                    sAttrType = "Mandatory";
                    continue;
                }
            }

            LdapValue[] attrValues = ldapNextEntry.GetAttributeValues(attr, dirnode.LdapContext);
            if (attrValues != null && attrValues.Length > 0)
            {
                foreach (LdapValue value in attrValues)
                {
                    //need do a type check before we assign the values, the type check has been done in getAttributeValues
                    sValue = sValue + ";" + value.stringData;
                }
                if (String.Equals(attr, "objectSid", StringComparison.InvariantCultureIgnoreCase))
                {
                    _parentDlg.objectSidBytes = attrValues[0].byteData;
                }
                if (String.Equals(attr, "objectGUID", StringComparison.InvariantCultureIgnoreCase))
                {
                    _parentDlg.objectGUIDBytes = attrValues[0].byteData;
                }
            }

            if (sValue.StartsWith(";"))
            {
                sValue = sValue.Substring(1).Trim();
            }

            if (string.Compare(sValue, "") == 0)
            {
                sValue = "<Not Set>";
            }

            SchemaType schemaType = schemaCache.GetSchemaTypeByDisplayName(attr);

            if (schemaType == null)
            {
                string[] addItem = null;
                string[] slvItem = {
                        attr,
                        "",
                        sValue,
                        sAttrType,
                        "false"
                    };
                if (String.Equals(attr, "objectGUID", StringComparison.InvariantCultureIgnoreCase) ||
                    String.Equals(attr, "objectSid", StringComparison.InvariantCultureIgnoreCase))
                {
                    slvItem[1] = "Octet String";
                }
                addItem = slvItem;
                ListViewItem lvItem = new ListViewItem(addItem);
                FillListView(AddNotset, attributeList, lvItem);
            }
            else
            {
                string sADSType = GetADSTypeString(schemaType);

                if (!String.Equals(sValue, "<Not Set>", StringComparison.InvariantCultureIgnoreCase) &&
                    String.Equals(schemaType.DataType.ToString(), ADSType.ADSTYPE_UTC_TIME.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    string sDate = "", sTime = "";
                    sDate = sValue.Substring(0, 4);
                    sDate += "/" + sValue.Substring(4, 2);
                    sDate += "/" + sValue.Substring(6, 2);

                    sTime = sValue.Substring(8, 2);
                    sTime += ":" + sValue.Substring(10, 2);
                    sTime += ":" + sValue.Substring(12, 2);

                    sValue = Convert.ToDateTime(sDate).ToShortDateString();
                    sValue += " " + Convert.ToDateTime(sTime).ToLongTimeString();
                }
                string[] slvItem = {
                        attr,
                        sADSType,
                        sValue,
                        sAttrType,
                        "false"
                    };
                ListViewItem lvItem = new ListViewItem(slvItem);
                lvItem.Tag = schemaType;
                FillListView(AddNotset, attributeList, lvItem);
            }
        }

        PopulateListView();
        _EditPageObject = new EditPageObject(lvAttrs);
    }