Пример #1
0
 public Help(int task = 0)
 {
     InitializeComponent();
     Icon = Properties.Resources.winicon;
     if (task == 1)
     {
         Text = "SuperADD: MDT Variables Dump";
         commandList.Items.Clear();
         TSEnvironment tsEnv = new TSEnvironment();
         foreach (string key in tsEnv.Variables)
         {
             commandList.Items.Add("Key: " + key + " Value: " + tsEnv[key]);
         }
     }
 }
Пример #2
0
        public Main(int autoIndex = -1, bool autoContinue = false)
        {
            InitializeComponent();
            titleText.Text = "SuperADD  |  v" + Application.ProductVersion.ToString();
            if (!File.Exists("SuperADD.xml"))
            {
                Config.GenerateConfig();
            }
            try
            {
                Config.ReadConfig();
            }
            catch (Exception e)
            {
                showMsg("SuperADD.xml: " + e.Message, warnImg);
                return;
            }
            try
            {
                new ProgressUI().CloseProgressDialog();
                tsEnv = new TSEnvironment();
                foreach (string key in tsEnv.Variables)
                {
                    if (key == "JOINDOMAIN")
                    {
                        adDomainName = tsEnv[key];
                    }
                    if (key == "USERID")
                    {
                        byte[] var = Convert.FromBase64String(tsEnv[key]);
                        adUserName = Encoding.UTF8.GetString(var);
                    }
                    if (key == "USERPASSWORD")
                    {
                        byte[] var = Convert.FromBase64String(tsEnv[key]);
                        adPassword = Encoding.UTF8.GetString(var);
                    }
                }
            }
            catch (COMException)
            {
                desktopMode      = true;
                WindowState      = FormWindowState.Normal;
                FormBorderStyle  = FormBorderStyle.Sizable;
                saveNextBtn.Text = "Save";
                skipJoinBtn.Hide();
                promptUsrTxt.Text = Environment.UserName;
                XElement domain = Config.Current.Element("DomainName");
                if (domain != null)
                {
                    promptDomTxt.Text = domain.Value;
                }
                else
                {
                    promptDomTxt.Text = IPGlobalProperties.GetIPGlobalProperties().DomainName;
                }
            }
            Icon               = Properties.Resources.winicon;
            autoRunIndex       = autoIndex;
            autoRunContinue    = autoContinue;
            pubFlowLayout      = flowPanel;
            pubDescTextBox     = descTextBox;
            pubAutoScaleFactor = new SizeF(
                CurrentAutoScaleDimensions.Width / 96,
                CurrentAutoScaleDimensions.Height / 96
                );
            XElement OUs = Config.Current.Element("OrganizationalUnits");

            if (OUs == null)
            {
                showMsg("OrganizationalUnits element missing from SuperADD.xml", warnImg);
                return;
            }
            foreach (XElement ou in OUs.Elements("OrganizationalUnit"))
            {
                XElement Name = ou.Element("Name");
                if (Name == null || ou.Element("DistinguishedName") == null)
                {
                    continue;
                }
                OUList.Items.Add(Name.Value);
                dirLookOUList.Items.Add(Name.Value);
            }
            XElement SGs = Config.Current.Element("SecurityGroups");

            if (SGs == null)
            {
                SGBox.Dispose();
            }
            else
            {
                bool empty = true;
                foreach (XElement sg in SGs.Elements("SecurityGroup"))
                {
                    XElement Name = sg.Element("Name");
                    if (Name == null || sg.Element("DistinguishedName") == null)
                    {
                        continue;
                    }
                    SGList.Items.Add(sg.Element("Name").Value);
                    empty = false;
                }
                if (empty)
                {
                    SGBox.Dispose();
                }
            }
            XElement DIs = Config.Current.Element("DescriptionItems");

            if (DIs == null)
            {
                showMsg("DescriptionItems element missing from SuperADD.xml", warnImg);
                return;
            }
            foreach (XElement descItem in DIs.Elements("DescriptionItem"))
            {
                XElement Name      = descItem.Element("Name");
                XElement Type      = descItem.Element("Type");
                XElement ListItems = descItem.Element("ListItems");
                if (Name == null || Type == null)
                {
                    continue;
                }
                descriptions.Add(Name.Value, null);
                if (Type.Value == "List")
                {
                    if (ListItems == null)
                    {
                        continue;
                    }
                    DescriptListItem listUnit = new DescriptListItem(Name.Value);
                    foreach (XElement listItem in ListItems.Elements("ListItem"))
                    {
                        listUnit.listBox.Items.Add(listItem.Value);
                    }
                }
                else if (Type.Value == "Text")
                {
                    DescriptTextItem listUnit = new DescriptTextItem(Name.Value);
                }
            }
            initialized = true;
        }