//Fill any server information in cache here to be retrieved by UI public void FillForwardZones() { UIErrorHelper.CheckedExec(delegate() { ForwardZones = ServerDTO.DNSClient.ListZones(VmDnsZoneType.FORWARD).ToList(); }); }
public void CreateSigningRequest() { var dto = new CertRequestDTO(); CreateCertificateWindowController cwc = new CreateCertificateWindowController(dto); NSApplication.SharedApplication.BeginSheet(cwc.Window, VMCAAppEnvironment.Instance.MainWindow, () => { }); try { nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window); if (result == (nint)Constants.DIALOGOK) { using (var request = new VMCARequest(this.ServerDTO.VMCAClient)) { dto.FillRequest(request); string csr = request.GetCSR(dto.PrivateKey.ToString()); this.ServerDTO.SigningRequests.Add(new SigningRequestDTO { CreatedDateTime = DateTime.Now, CSR = csr }); GenericTextViewWindowController gwc = new GenericTextViewWindowController(csr); gwc.Window.Title = "CSR Data"; NSApplication.SharedApplication.RunModalForWindow(gwc.Window); NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this); } } } catch (Exception e) { UIErrorHelper.ShowAlert(e.Message, "Operation could not complete successfully."); } finally { VMCAAppEnvironment.Instance.MainWindow.EndSheet(cwc.Window); cwc.Dispose(); } }
public void RemoveStoreInfo(string storename) { UIErrorHelper.CheckedExec(delegate() { StoresInfo.Remove(storename); CalculateKeyInfo(); }); }
private bool DoValidate() { var requiredPropsNotFilled = _properties.Where(x => { var val = x.Value; if (val.Value == null) { return(true); } if (val.Value is string) { return(string.IsNullOrEmpty(val.Value as string)); } else if (val.Value is List <string> ) { return((val.Value as List <string>).Count == 0); } return(false); }); if (requiredPropsNotFilled.Count() > 0) { string error = string.Format("{0} is empty", requiredPropsNotFilled.First().Key); UIErrorHelper.ShowAlert("", error); return(false); } return(true); }
public void OnClickOkButton(object sender, EventArgs eventargs) { try { if (PrivateKeyOptions.SelectedTag == 2) { if (string.IsNullOrEmpty(FilePath.StringValue)) { throw new Exception("One or more field empty"); } PrivateKeyDTO.PrivateKeyFileName = FilePath.StringValue; } else { if (string.IsNullOrEmpty(PrivateKeyTextView.Value)) { throw new Exception("One or more field empty"); } PrivateKeyDTO.PrivateKeyString = PrivateKeyTextView.Value; } this.Close(); NSApplication.SharedApplication.StopModalWithCode(1); } catch (Exception e) { UIErrorHelper.ShowAlert("", e.Message); } }
private void AddButton_Click_1(object sender, EventArgs e) { UIErrorHelper.CheckedExecNonModal(delegate() { if (this.AddButton.Text == VMwareMMCIDP.UI.Common.Utilities.MMCUIConstants.EDIT) { SetUIToolsEditability(); this.AddButton.Text = VMwareMMCIDP.UI.Common.Utilities.MMCUIConstants.UPDATE; } else if (UIErrorHelper.ShowConfirm(VMwareMMCIDP.UI.Common.Utilities.MMCUIConstants.CONFIRM) == DialogResult.Yes) { DoValidateControls(); FillDTOWithUIControls(); this.Close(); this.DialogResult = DialogResult.OK; } }); }
private void UpdateStatus() { try { _enabled = SuperLog.isEnabled(); if (_enabled) { uint nCapacity = SuperLog.getCapacity(); Status.StringValue = string.Format( "Superlogging is on with a buffer size of {0} entries", nCapacity); TxtBufferSize.IntValue = (int)nCapacity; pageSize = TxtBufferSize.IntValue; } else { Status.StringValue = "Superlogging is turned off. Click the button to turn it on"; } BtnBufferSizeChange.Enabled = TxtBufferSize.Enabled = _enabled; } catch (Exception exc) { if (ChkAutoRefresh.StringValue == "1") { ChkAutoRefresh.StringValue = "0"; timer.Change(-1, -1); } _enabled = false; Status.StringValue = "Superlogging is turned off. Click the button to turn it on"; BtnBufferSizeChange.Enabled = TxtBufferSize.Enabled = true; UIErrorHelper.ShowAlert(exc.Message, "Operation could not complete successfully."); } BtnOff.Title = "Turn " + (_enabled ? "OFF" : "ON"); }
public void ShowRootCertificate() { UIErrorHelper.CheckedExec(delegate() { var cert = ServerDTO.VMCAClient.GetRootCertificate(); CertificateService.DisplayX509Certificate2(this, cert); }); }
public override VmDnsRecord GetRecordDataFromUIFields() { VmDnsRecord addressRecord = null; UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); var data = new VMDNS_SRV_DATA(); data.pNameTarget = AddRecordFrm.SRVRecordTargetHostText.Text; data.wPriority = Convert.ToUInt16(AddRecordFrm.SRVRecordPriorityText.Text); data.wWeight = Convert.ToUInt16(AddRecordFrm.SRVRecordWeightText.Text); data.wPort = Convert.ToUInt16(AddRecordFrm.SRVPortText.Text); var record = new VMDNS_RECORD_SRV(); record.data = data; record.common.iClass = 1; record.common.pszName = "_" + AddRecordFrm.SRVRecordServiceCombo.Text + "._" + AddRecordFrm.SRVRecordProtocolCombo.Text; record.common.type = (UInt16)RecordType.VMDNS_RR_TYPE_SRV; addressRecord = new VmDnsRecordSRV(record); }); return(addressRecord); }
public override void AwakeFromNib() { base.AwakeFromNib(); try { Window.SetContentBorderThickness(24, NSRectEdge.MinYEdge); VMDirSnapInEnvironment.Instance.MainWindow = this.Window; //Load SplitView splitViewController = new SplitViewMMCController(); splitViewController.MainOutlineView = new OutlineView(); splitViewController.MainTableView = new VMDirTableView(); this.ContainerView.AddSubview(splitViewController.View); SetToolBarState(false); (NSApplication.SharedApplication.Delegate as AppDelegate).OpenConnectionMenuITem.Hidden = true; //Notifications for OutlineView and Tableview to reload ReloadOutlineViewNotificationObject = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"ReloadOutlineView", ReloadOutlineView); ReloadTableViewNotificationObject = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"ReloadTableView", ReloadTableView); CloseNotificationObject = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"CloseApplication", OnCloseConnectionNotificationReceived); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Error : " + e.Message); UIErrorHelper.ShowAlert("", e.Message); } }
private bool Validate() { int ps; if (string.IsNullOrWhiteSpace(PageSizeTextField.StringValue)) { UIErrorHelper.ShowWarning(VMDirConstants.WRN_PAGE_SIZE); return(false); } if (int.TryParse(PageSizeTextField.StringValue, out ps)) { if (ps <= 0) { UIErrorHelper.ShowWarning(VMDirConstants.WRN_PAGE_SIZE_MINVAL); return(false); } else if (ps > VMDirConstants.DEFAULT_PAGE_SIZE * 10) { UIErrorHelper.ShowWarning(VMDirConstants.WRN_PAGE_SIZE_MAXVAL); return(false); } else { return(true); } } else { UIErrorHelper.ShowWarning(VMDirConstants.WRN_INT_VAL); return(false); } }
private void InitialiseViews() { AppDelegate appDelegate = NSApplication.SharedApplication.Delegate as AppDelegate; appDelegate.OpenConnectionMenuITem.Hidden = true; try { if (serverNode.IsLoggedIn) { InitialiseDefaultOutlineView(); VMDirSnapInEnvironment.Instance.LocalData.AddServer(serverNode.DTO.Server); DirectoryNode baseNode = new DirectoryNode(serverNode.DTO.BaseDN, serverNode.DTO, null); baseNode.IsBaseNode = true; outlineViewDataSource = new OutlineViewDataSource(baseNode); splitViewController.MainOutlineView.DataSource = outlineViewDataSource; baseNode.PopulateChildren(serverNode.DTO.BaseDN); SetToolBarState(true); InitialiseDefaultTableView(); StatusLabel.StringValue = "Logged in : " + serverNode.DTO.BindDN; } else { UIErrorHelper.ShowAlert("Please check your server details and credentials.", "Login not successful!"); } } catch (Exception e) { CloseConnection(); UIErrorHelper.ShowAlert(e.Message, "Error in populating the directory. Please check the login details and try again"); } }
public void FillForwarders() { UIErrorHelper.CheckedExec(delegate() { Forwarders = ServerDTO.DNSClient.GetForwarders().ToList(); }); }
public void FillReverseZones() { UIErrorHelper.CheckedExec(delegate() { ReverseZones = ServerDTO.DNSClient.ListZones(VmDnsZoneType.REVERSE).ToList(); }); }
public void OnClickOKButton(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(UserNameTxtField.StringValue) || string.IsNullOrWhiteSpace(PasswordTxtField.StringValue) || string.IsNullOrWhiteSpace(ServerTxtField.StringValue)) { UIErrorHelper.ShowAlert("", "Please enter values in the username and password"); } else { Upn = UserNameTxtField.StringValue; String[] userAndDomain = Upn.Split('@'); if (userAndDomain.Length != 2) { UIErrorHelper.ShowAlert("", "Enter Valid User Principal Name"); } else { UserName = userAndDomain [0]; DomainName = userAndDomain [1]; Password = PasswordTxtField.StringValue; Server = ServerTxtField.StringValue; this.Close(); NSApplication.SharedApplication.StopModalWithCode(1); } } }
public override void SetUIFieldsFromRecordData(VmDnsRecord record) { VmDnsRecordSRV srvRecord = record as VmDnsRecordSRV; if (srvRecord != null) { AddRecordFrm.SRVRecordTargetHostText.Text = srvRecord.Target; AddRecordFrm.SRVRecordPriorityText.Text = srvRecord.Priority.ToString(); AddRecordFrm.SRVRecordWeightText.Text = srvRecord.Weight.ToString(); AddRecordFrm.SRVPortText.Text = srvRecord.Port.ToString(); AddRecordFrm.SRVRecordProtocolNameText.Visible = true; AddRecordFrm.SRVRecordProtocolNameText.Text = srvRecord.Name; AddRecordFrm.SRVRecordProtocolLabel.Visible = true; AddRecordFrm.SRVRecordProtocolCombo.Visible = false; AddRecordFrm.SRVRecordServiceCombo.Visible = false; AddRecordFrm.SRVRecordServiceLabel.Visible = false; } else { UIErrorHelper.ShowMessage("Unknown Record Format"); } }
public void OnClickOKButton(object sender, EventArgs e) { try { DoValidate(); if (_properties.Count > 0 && ds.PendingMod.Count > 0) { LdapMod[] user = new LdapMod[ds.PendingMod.Count]; int i = 0; foreach (var entry in ds.PendingMod) { string[] entries = entry.Value.Split(','); string[] values = new string[entries.Length + 1]; entries.CopyTo(values, 0); values [entries.Length] = null; user [i] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_REPLACE, entry.Key, values); i++; } serverDTO.Connection.ModifyObject(itemName, user); } } catch (Exception ex) { UIErrorHelper.ShowAlert("", ex.Message); } finally { this.Close(); NSApplication.SharedApplication.StopModalWithCode(1); } }
private void MoveForwarderUp(object sender, EventArgs e) { int selectedRow = (int)this.ForwardersList.SelectedIndex; if (selectedRow > 0) { UIErrorHelper.CheckedExec(delegate() { //TODO - revisit and cleanup when https://bugzilla.eng.vmware.com/show_bug.cgi?id=1541111 is fixed string temp = ServerNode.Forwarders[selectedRow]; //ServerNode.ServerDTO.DNSClient.DeleteForwarder(selectedRow); ServerNode.Forwarders.RemoveAt(selectedRow); //ServerNode.ServerDTO.DNSClient.InsertForwarder(temp, selectedRow - 1); ServerNode.Forwarders.Insert(selectedRow - 1, temp); }); //Verify if forwarders is updated } }
partial void OnCompare(Foundation.NSObject sender) { try { switch (this.CompareRadioMatrix.SelectedTag) { case 0: ViewAttributeTypeDiffButton.Hidden = false; ViewObjectClassDiffButton.Hidden = false; ViewObjectClassDiffButton.Title = VMDirSchemaConstants.DIFF_OBJECTCLASS; attrTypediff = ServerNode.ServerDTO.Connection.SchemaConnection.GetAllSchemaDefinitionDiffs(); SetNodesDataSource(attrTypediff); break; case 1: ViewAttributeTypeDiffButton.Hidden = true; ViewObjectClassDiffButton.Hidden = false; ViewObjectClassDiffButton.Title = VMDirSchemaConstants.DIFF_METADATA; schemaDiff = ServerNode.ServerDTO.Connection.SchemaConnection.GetAllSchemaMetadataDiffs(); SetNodesDataSourceForMetaData(schemaDiff); break; default: break; } } catch (Exception e) { UIErrorHelper.ShowAlert(e.Message, String.Empty); } }
private void OK_Click(object sender, EventArgs e) { UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); ZoneInfo = new VMDNS_ZONE_INFO() { pszName = HostNameText.Text, pszRName = AdminEmailText.Text, pszPrimaryDnsSrvName = NetworkIDText.Text + "\\" + NetworkIDLengthText.Text, dwZoneType = (uint)VmDnsZoneType.FORWARD }; this.Close(); this.DialogResult = DialogResult.OK; }); }
protected override void OnInitialize(AsyncStatus status) { base.OnInitialize(status); this.Columns[0].Title = VMDirSchemaConstants.VMDIRSCHEMA_NAME; this.Columns[0].SetWidth(130); this.Columns.Add(new MmcListViewColumn(VMDirSchemaConstants.VMDIRSCHEMA_ATTR_SYNTAX, 130)); this.Columns.Add(new MmcListViewColumn(VMDirSchemaConstants.VMDIRSCHEMA_DESC, 130)); this.Mode = MmcListViewMode.Report; (this.ScopeNode as VMDirSchemaAttributeBaseNode).ListView = this; UIErrorHelper.CheckedExec(delegate() { Refresh(); }); }
public override VmDnsRecord GetRecordDataFromUIFields() { VmDnsRecord addressRecord = null; UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); var data = new VMDNS_PTR_DATA(); data.hostName = AddRecordFrm.CNameRecordHostNameText.Text; var record = new VMDNS_RECORD_CNAME(); record.data = data; record.common.iClass = 1; record.common.pszName = AddRecordFrm.CNameRecordNameText.Text; record.common.type = (UInt16)RecordType.VMDNS_RR_TYPE_CNAME; addressRecord = new VmDnsRecordCNAME(record); }); return(addressRecord); }
public override VmDnsRecord GetRecordDataFromUIFields() { VmDnsRecord addressRecord = null; UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); var data = new VMDNS_AAAA_DATA(); var addr = IPAddress.Parse(AddRecordFrm.AAAARecordHostIP.Text); data.Ip6Address.bytes = addr.GetAddressBytes(); var record = new VMDNS_RECORD_AAAA(); record.common.iClass = 1; record.common.pszName = AddRecordFrm.AAAARecordHostNameText.Text; record.common.type = (UInt16)RecordType.VMDNS_RR_TYPE_AAAA; record.data = data; addressRecord = new VmDnsRecordAAAA(record); }); return(addressRecord); }
protected override void OnInitialize(AsyncStatus status) { base.OnInitialize(status); this.Columns[0].Title = VMDNSConstants.ZONE_NAME; this.Columns[0].SetWidth(130); this.Columns.Add(new MmcListViewColumn(VMDNSConstants.DNS_NAME, 130)); this.Columns.Add(new MmcListViewColumn(VMDNSConstants.ADMIN_EMAIL, 130)); this.Mode = MmcListViewMode.Report; (this.ScopeNode as VMDNSZonesBaseNode).ListView = this; UIErrorHelper.CheckedExec(delegate() { Refresh(); }); }
public void RefreshChildren() { UIErrorHelper.CheckedExec(delegate() { this.Children.Clear(); this.objectClasses.Clear(); objectClassManager = this.ServerNode.ServerDTO.Connection.SchemaManager.GetObjectClassManager(); var data = objectClassManager.Data; foreach (var entry in data) { objectClasses.Add(new VMDirSchemaClassEntryNode(this.ServerNode, entry.Value)); } objectClasses = objectClasses.OrderBy(o => o.DisplayName).ToList(); this.Children.AddRange(objectClasses.ToArray()); }); }
private void EditButton_Click(object sender, EventArgs e) { if (this.EditButton.Text == VMDNSConstants.EDIT) { this.EditButton.Text = VMDNSConstants.UPDATE; ToggleUIControlsState(true); } else { UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); SetZoneValuesFromUIFields(); //close dialog and return }); } }
partial void OnExport(NSObject sender) { if (!ValidateExport()) { return; } UIErrorHelper.CheckedExec(delegate { StringBuilder sb = new StringBuilder(); var start = 0; var end = _resultList.Count; if (ScopeComboBox.SelectedIndex == (int)ExportScope.CURR_PAGE) { start = (_currPage - 1) * _pageSize; end = _currPage * _pageSize > _resultList.Count ? _resultList.Count : _currPage * _pageSize; } HashSet <string> attrToExport = new HashSet <string>(); if (AllReturnAttrCheckBox.State == NSCellStateValue.On) { foreach (var item in _returnedAttrList) { attrToExport.Add(item); } } else { foreach (var item in _attrToExportDs.attrList) { attrToExport.Add(item); } } foreach (var item in attrToExport) { sb.Append(item + ","); } sb.Append(Environment.NewLine); for (var i = start; i < end; i++) { foreach (var item in attrToExport) { sb.Append("\""); if (_resultList[i].NodeProperties.ContainsKey(item)) { foreach (var val in _resultList[i].NodeProperties[item].Values) { sb.Append(val.StringValue + " "); } } sb.Append("\""); sb.Append(","); } sb.Append(Environment.NewLine); } if (FileIOUtil.WriteAllTextToFile(sb.ToString(), "Export Result", new string[] { "csv" })) { UIErrorHelper.ShowInformation(VMDirConstants.STAT_RES_EXPO_SUCC); } }); }
public override VmDnsRecord GetRecordDataFromUIFields() { VmDnsRecord addressRecord = null; UIErrorHelper.CheckedExec(delegate() { DoValidateControls(); var data = new VMDNS_A_DATA(); data.IpAddress = (UInt32)IPAddress.NetworkToHostOrder( (int)IPAddress.Parse(AddRecordFrm.ARecordHostIPText.Text).Address); VMDNS_RECORD_A record = new VMDNS_RECORD_A(); record.data = data; record.common.iClass = 1; record.common.pszName = AddRecordFrm.ARecordHostNameText.Text; record.common.type = (UInt16)RecordType.VMDNS_RR_TYPE_A; addressRecord = new VmDnsRecordA(record); }); return(addressRecord); }
public void UpdateStoreInfo(string storename) { UIErrorHelper.CheckedExec(delegate() { if (storename != null) { string storePass = ""; using (var session = new VecsStoreSession(ServerDTO.VecsClient, storename, storePass)) { // update store info if (StoresInfo.ContainsKey(storename)) { StoresInfo [storename] = new CertBagItem() { PrivateKeys = session.GetPrivateKeys().Concat(session.GetEncryptedPrivateKeys()).ToList(), SecretKeys = session.GetSecretKeys().ToList(), Certs = session.GetCertificates().ToList() }; CalculateKeyInfo(); } else { StoresInfo.Add(storename, new CertBagItem() { PrivateKeys = session.GetPrivateKeys().Concat(session.GetEncryptedPrivateKeys()).ToList(), SecretKeys = session.GetSecretKeys().ToList(), Certs = session.GetCertificates().ToList() }); NoStores++; } } } }); }
public void OnShowActiveDirectory(object sender, EventArgs e) { ActionHelper.Execute(delegate() { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(DisplayName); var adJoinInfoDto = SnapInContext.Instance.ServiceGateway.Adf.GetActiveDirectory(auth.ServerDto, auth.Token); if (adJoinInfoDto == null || (adJoinInfoDto != null && adJoinInfoDto.JoinStatus != "DOMAIN")) { var form = new JoinActiveDirectoryController(); var result = NSApplication.SharedApplication.RunModalForWindow(form.Window); if (result == VMIdentityConstants.DIALOGOK) { var user = JoinActiveDirectory(form.ActiveDirectoryJoinRequestDto); if (user != null) { UIErrorHelper.ShowAlert("AD join operation was successful. Please reboot the node.", "Information"); } } } else { var form = new LeaveActiveDirectoryController() { ActiveDirectoryJoinInfoDto = adJoinInfoDto, Server = DisplayName }; NSApplication.SharedApplication.RunModalForWindow(form.Window); } }); }