public EucaConfigForm() { try { string installLocation = (string)EucaUtil.GetRegistryValue(Registry.LocalMachine, EUCALYPTUS_REGISTRY_PATH, "InstallLocation"); EucaLogger.LogLocation = string.Format("{0}\\eucalog.txt", installLocation); } catch (Exception e) { MessageBox.Show(string.Format("Unexpected exception thrown: {0}", e.Message)); return; } InitializeComponent(); // using (System.Drawing.Bitmap bm = new System.Drawing.Bitmap(EucaConstant.ProgramRoot+"\\euca.png")) // this.Icon = System.Drawing.Icon.FromHandle(bm.GetHicon()); InitPanel(); }
private void InitPanel() { /// check if the instance is a member of an AD /// bool partOfDomain = false; string domain = null; try { using (ManagementObject comObj = WMIUtil.QueryLocalWMI("Select * from win32_computersystem")) { partOfDomain = (bool)comObj["PartOfDomain"]; domain = (string)comObj["Domain"]; } if (partOfDomain) { labelADStatus.Text = string.Format("domain member of {0}", domain); // buttonUnregister.Enabled = true; // buttonUnregister.Visible = true; } else { labelADStatus.Text = "not a member of a domain"; } } catch (Exception e) { EucaLogger.Exception("Can't determine if the host is a part of domain", e); labelADStatus.Text = "error-AD status could not be determined"; } object tmp = EucaServiceLibraryUtil.GetSvcRegistryValue("ADAddress"); if (tmp != null) { _adConfig.ADAddress = (string)tmp; } tmp = EucaServiceLibraryUtil.GetSvcRegistryValue("ADUsername"); if (tmp != null) { _adConfig.ADUsername = (string)tmp; } tmp = EucaServiceLibraryUtil.GetSvcRegistryValue("ADPassword"); { if (tmp != null) { _adConfig.ADPassword = EucaUtil.Decrypt((string)tmp); } } tmp = EucaServiceLibraryUtil.GetSvcRegistryValue("ADOU"); if (tmp != null) { _adConfig.ADOU = (string)tmp; } if (_adConfig.ADAddress != null) { textBoxADAddress.Text = _adConfig.ADAddress; } if (_adConfig.ADUsername != null) { textBoxADUsername.Text = _adConfig.ADUsername; } if (_adConfig.ADPassword != null) { textBoxADPassword.Text = _adConfig.ADPassword; } if (_adConfig.ADOU != null) { textBoxADOU.Text = _adConfig.ADOU; } /// bring up the list of users/groups that has RD permission on the image string[] rdPermissionUsers = null; try { rdPermissionUsers = this.GetRDPermissionUsers(); } catch (Exception e) { EucaLogger.Exception("Could not enumerate RD users/groups from registry", e); } if (rdPermissionUsers != null) { foreach (string name in rdPermissionUsers) { listBoxRDPermission.Items.Add(name); } } buttonApply.Enabled = false; try { int selected = (int)EucaUtil.GetRegistryValue(Registry.LocalMachine, EUCALYPTUS_REGISTRY_PATH, "FormatDrives"); if (selected == 1) { checkBoxFormatDrives.Checked = true; } else { checkBoxFormatDrives.Checked = false; } } catch (Exception e) { EucaLogger.Exception("Couldn't check 'FormatDrives' option from registry", e); } }