Example #1
0
        public static int AddLocalAddressRange(string startAddress, string endAddress)
        {
            CheckAccess();

            int id;
            // Validate range
            IPAddressRange range = new IPAddressRange(startAddress, endAddress);

            // Add range
            using(DbTransaction tran = DbTransaction.Begin())
            {
                id = DbActiveDirectory.LocalAddressRangeAdd(startAddress, endAddress);
                tran.Commit();
            }
            return id;
        }
Example #2
0
        public static void UpdateLocalAddressRanges(DataTable items)
        {
            CheckAccess();

            ArrayList oldItems = GetLocalAddressesList();

            ArrayList add = new ArrayList();
            ArrayList del = new ArrayList();
            foreach(DataRow row in items.Rows)
            {
                IPAddressRange item = new IPAddressRange((string)row["StartAddress"], (string)row["EndAddress"]);
                if(oldItems.Contains(item))
                    oldItems.Remove(item);
                else
                    add.Add(item);
            }

            del.AddRange(oldItems);

            using(DbTransaction tran = DbTransaction.Begin())
            {
                foreach(IPAddressRange range in add)
                {
                    DbActiveDirectory.LocalAddressRangeAdd(range.StartAddress.ToString(), range.EndAddress.ToString());
                }

                foreach(IPAddressRange range in del)
                {
                    DbActiveDirectory.LocalAddressRangeDelete(range.ID);
                }

                tran.Commit();
            }
        }
Example #3
0
        public static void UpdateLocalAddressRange(int rangeId, string startAddress, string endAddress)
        {
            CheckAccess();

            // Validate range
            IPAddressRange range = new IPAddressRange(rangeId, startAddress, endAddress);

            // Update range
            using(DbTransaction tran = DbTransaction.Begin())
            {
                DbActiveDirectory.LocalAddressRangeUpdate(rangeId, startAddress, endAddress);
                tran.Commit();
            }
        }