Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            update = false;
            CheckForUpdate();

            if (update)
            {
                Process.Start(Directory.GetCurrentDirectory() + "\\edupdater.exe");
                Close();
                return;
            }

            screen = new Splash(this);
            screen.ShowDialog();

            StartRef = startDeploy;
            MainFormAccess.Init(this);

            LocalNetworkSettings.CheckForLocalDNSServers();
            AppConsole.Init(consoleDisplay, this);
            commandList   = new List <String>();
            username.Text = Environment.UserDomainName + "\\" + Environment.UserName;
            username.Select(username.Text.Length, 0);
            listMaker.initUseList(selectedComputers);
            deployTo.SelectedIndex = 2;
            priority.SelectedIndex = 2;
            //loadEasyFile();
        }
Пример #2
0
        private void getSubnets()
        {
            LocalNetworkSettings.GetLocalSubnets();
            subnetsToolStripMenuItem.DropDownItems.Clear();
            foreach (String s in LocalNetworkSettings.AvailableSubnets)
            {
                subnetsToolStripMenuItem.DropDownItems.Add(s);
                subnetsToolStripMenuItem.DropDownItems[subnetsToolStripMenuItem.DropDownItems.Count - 1].Click += new EventHandler(subnetDropDownMenuItem_Click);
            }

            octet1.Value = LocalNetworkSettings.subnetParseOctet1;
            octet2.Value = LocalNetworkSettings.subnetParseOctet2;
            octet3.Value = LocalNetworkSettings.subnetParseOctet3;

#if DEBUG
            LocalNetworkSettings.DnsOK = true;
            return;
#endif

            // Check if any of the Available DNS Server are local DNS Servers
            foreach (String s in LocalNetworkSettings.AvailableDNSServers)
            {
                for (int i = 0; i < subnetsToolStripMenuItem.DropDownItems.Count; i++)
                {
                    if (s.Substring(0, octet1.Value.ToString().Length) == subnetsToolStripMenuItem.DropDownItems[i].ToString().Substring(0, octet1.Value.ToString().Length))
                    {
                        LocalNetworkSettings.DnsOK = true;
                        break;
                    }
                }
            }
        }
Пример #3
0
    static public void GetComputers()
    {
        LocalNetworkSettings.GetLocalIPAddress();

        if (Environment.UserDomainName.ToUpper() == Environment.MachineName)
        {
            adNotAvailable = true;
            return;
        }

        try
        {
            // get root of the directory data tree on a directory server
            DirectoryEntry dirEntry = new DirectoryEntry("LDAP://rootDSE");
            // get the hostname of the directory server of your root (I'm assuming that's what you want)
            string      dnsHostname = dirEntry.Properties["dnsHostname"].Value.ToString();
            IPAddress[] ipAddresses = Dns.GetHostAddresses(dnsHostname);

            Ping pingSender = new Ping();

            for (int i = 0; i < ipAddresses.Count(); i++)
            {
                try
                {
                    PingReply reply = pingSender.Send(ipAddresses[i].ToString(), 1000);
                    if (reply.Status == IPStatus.Success)
                    {
                        DCAvailable = true;
                        break;
                    }
                }

                catch {}
            }
        }

        catch { }

        cacheFound = false;
        CachedAD.Clear();

        if (File.Exists("adcache.xml"))
        {
            ActiveDirCacheFile cache = LoadCacheFile();

            if (Environment.UserDomainName == cache.DomainName)
            {
                cacheFound = true;
                LastUpdate = File.GetLastWriteTime("adcache.xml");

                foreach (String s in cache.Computers)
                {
                    CachedAD.Add(s);
                }
            }
        }

        if (cacheFound && Settings.AUTO_UPDATE_AD_ON_STARTUP)
        {
            Thread UpdateThread = new Thread(new ThreadStart(BeginADDownload));
            UpdateThread.Start();
        }

        else if (cacheFound && !Settings.AUTO_UPDATE_AD_ON_STARTUP)
        {
            AppConsole.WriteLine("Cached AD was loaded.");
        }

        else
        {
            if (adUpToDate)
            {
                MessageBox.Show("Please wait!\n\nError: Cahced AD was not found.\n\nClick OK to continue. This process can take several minutes.", "Active Directory Updating", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            BeginADDownload();
        }
    }