Esempio n. 1
0
        /// <summary>
        /// return Datatable from container
        /// </summary>
        /// <param name="aDContainer"></param>
        public DataTable FillDataTableFromADContainer(DirectoryEntry aDContainer)
        {
            try
            {
                if (aDContainer == null)
                {
                    return(null);
                }
                DataTable containerData = new DataTable();
                containerData.Columns.Add("Property", typeof(string));
                containerData.Columns.Add("Value", typeof(string));
                foreach (object ADProperties in aDContainer.Properties.PropertyNames)
                {
                    if (!(ADProperties.ToString().Contains("ms-Mcs-AdmPwdExpirationTime") | (ADProperties.ToString().Contains("ms-Mcs-AdmPwd"))))
                    {
                        IADsPropertyList  oPropList  = (aDContainer.NativeObject as IADsPropertyList);
                        IADsPropertyEntry oPropEntry = (oPropList.GetPropertyItem(ADProperties.ToString(), (int)ADSTYPEENUM.ADSTYPE_UNKNOWN) as IADsPropertyEntry);
                        int    iADsType = oPropEntry.ADsType;
                        string teste    = PropertyToString(aDContainer, oPropEntry, iADsType);
                        containerData.Rows.Add(ADProperties.ToString(), teste);

                        // ListViewItem ListItem = new ListViewItem(ADProperties.ToString(), 0);
                        //ListItem.SubItems.Add(PropertyToString(aDContainer, oPropEntry, iADsType));
                    }
                }
                return(containerData);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while populating the Datatable", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Populates the list from the container which was clicked on the treeview
        /// </summary>
        /// <param name="aDContainer"></param>
        public void FillListViewFromADContainer(ref ListView ctr_list, DirectoryEntry aDContainer)
        {
            //Fill the ListView Element
            try
            {
                if (aDContainer == null)
                {
                    return;
                }
                ctr_list.Items.Clear();

                foreach (object ADProperties in aDContainer.Properties.PropertyNames)
                {
                    if (!(ADProperties.ToString().Contains("ms-Mcs-AdmPwdExpirationTime") | (ADProperties.ToString().Contains("ms-Mcs-AdmPwd"))))
                    {
                        IADsPropertyList  oPropList  = (aDContainer.NativeObject as IADsPropertyList);
                        IADsPropertyEntry oPropEntry = (oPropList.GetPropertyItem(ADProperties.ToString(), (int)ADSTYPEENUM.ADSTYPE_UNKNOWN) as IADsPropertyEntry);
                        int iADsType = oPropEntry.ADsType;

                        ListViewItem ListItem = new ListViewItem(ADProperties.ToString(), 0);
                        ListItem.SubItems.Add(PropertyToString(aDContainer, oPropEntry, iADsType));
                        ctr_list.Items.AddRange(new ListViewItem[] { ListItem });
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while populating the list", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }