Пример #1
0
        /// <summary>
        /// Поик и отпускания в БД наименования рабочих станций
        /// </summary>
        /// <param name="pathdomain">путь к домену конечной точки</param>
        /// <param name="workstation">Рабочии станции</param>
        public void FindIpHost(string pathdomain, string workstation)
        {
            var directoryEntry = new DirectoryEntry("LDAP://regions.tax.nalog.ru")
            {
                Path = pathdomain
            };
            DirectorySearcher searcher = new DirectorySearcher(directoryEntry)
            {
                Filter = workstation
            };
            var         allhost = searcher.FindAll();
            AddObjectDb add     = new AddObjectDb();
            ComputerIpAdressSynhronization synhronization = new ComputerIpAdressSynhronization();

            add.ClearsHostSynhronization();
            add.IsProcessComplete(1, false);
            Regex ip = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");

            foreach (SearchResult find in allhost)
            {
                var namecomputers = find.GetDirectoryEntry().Name.Replace("CN=", "");
                try
                {
                    IPAddress[] adress = Dns.GetHostAddresses(namecomputers);
                    byte[]      ab     = new byte[6];
                    int         len    = ab.Length;
                    int         r      = SendARP(BitConverter.ToInt32(adress[0].GetAddressBytes(), 0), 0, ab, ref len);
                    string      mac    = BitConverter.ToString(ab, 0, 6);
                    synhronization.IpAdress  = adress[0].ToString();
                    synhronization.NameHost  = namecomputers;
                    synhronization.MacAdress = mac;
                    synhronization.StatusIp  = null;
                    synhronization.UserName  = null;
                    add.AddHostSynhronization(synhronization);
                }
                catch (Exception exception)
                {
                    synhronization.IpAdress  = null;
                    synhronization.NameHost  = namecomputers;
                    synhronization.MacAdress = null;
                    synhronization.StatusIp  = exception.Message;
                    synhronization.UserName  = null;
                    add.AddHostSynhronization(synhronization);
                }
            }
            add.IsProcessComplete(1, true);
        }
Пример #2
0
        public void Inven()
        {
            AddObjectDb add = new AddObjectDb();

            add.IsProcessComplete(1, false);
        }