private void DoConnect2() { if (Clients.Connected) { Clients.Connected = false; toolStripMenuItem_FileConnect.Text = "&Connect"; statusStripLabel_Connection.Text = "Disconnected. Click the Connect button..."; toolStripButton_Connect.Image = global::iRuler.Properties.Resources.ToolbarConnect; toolStripButton_Connect.Text = "Connect"; //treeView_iRules.Nodes.Clear(); treeView_iRules.Nodes.Remove(m_treeNodeConfiguration); treeView_iRules.Nodes.Remove(m_treeNodeLocalLB); treeView_iRules.Nodes.Remove(m_treeNodeGlobalLB); m_textEditor.Text = ""; m_lastTreeViewNode = null; showButtons(false); setStatus("Disconnected", getStatusVisible()); m_currentPartition = ""; updateTitle(false); } else { //ConnectionDialog cd = new ConnectionDialog(); iControl.Dialogs.ConnectionDialog cd = new iControl.Dialogs.ConnectionDialog(); cd.ConnectionInfo = Clients.ConnectionInfo; cd.centerX = this.Location.X + (this.Width / 2); cd.centerY = this.Location.Y + (this.Height / 2); DialogResult dr = cd.ShowDialog(this); if (DialogResult.OK == dr) { Clients.initialize(); toolStripMenuItem_FileConnect.Text = "Dis&connect"; toolStripButton_Connect.Image = global::iRuler.Properties.Resources.ToolbarDisconnect; toolStripButton_Connect.Text = "Disconnect. Click the Connect button..."; statusStripLabel_Connection.Text = "Connected to " + Clients.ConnectionInfo.hostname; setStatus(statusStripLabel_Connection.Text, getStatusVisible()); updatePartitionInfo(); //updateFolderInfo(); refreshiRules(); showButtons(true); updateTitle(false); } else { setStatus("The host you have specified must be a v9.x BIG-IP", true); } } }
protected override void ProcessRecord() { if (validCredentials()) { if (!isInitialized()) { Globals._interfaces = new iControl.Interfaces(); } bool initialized = false; if (!string.IsNullOrEmpty(_auth_client_ip) && !string.IsNullOrEmpty(_auth_token)) { // "EM" based Token Authentication String[] sSplit = _hostname.Split(new char[] { ':' }); initialized = (2 == sSplit.Length) ? GetiControl().initializeWithToken(sSplit[0], Convert.ToUInt32(sSplit[1]), _auth_client_ip, _auth_token) : GetiControl().initializeWithToken(_hostname, _auth_client_ip, _auth_token); } else { // Basic Authentication if (string.IsNullOrEmpty(_username) || (string.IsNullOrEmpty(_password))) { iControl.Dialogs.ConnectionDialog connDlg = new iControl.Dialogs.ConnectionDialog(); DialogResult dr = connDlg.ShowDialog(); if (DialogResult.OK == dr) { _username = connDlg.Credentials.UserName; _password = connDlg.Credentials.Password; WebProxy proxy = connDlg.ConnectionInfo.getWebProxy(); if (null != proxy) { _proxy_address = proxy.Address.Host; _proxy_port = proxy.Address.Port; if (null != proxy.Credentials) { _proxy_user = ((NetworkCredential)proxy.Credentials).UserName; _proxy_pass = ((NetworkCredential)proxy.Credentials).Password; } } } } if (!string.IsNullOrEmpty(_username) && !(string.IsNullOrEmpty(_password))) { String[] sSplit = _hostname.Split(new char[] { ':' }); String hostname = sSplit[0]; long port = 443; if (2 == sSplit.Length) { port = Convert.ToInt32(sSplit[1]); } Boolean use_https = (443 == port) | !_force_http; if ((null != _proxy_address) && (0 != _proxy_port)) { initialized = GetiControl().initialize(hostname, port, _username, _password, _proxy_address, _proxy_port, _proxy_user, _proxy_pass, use_https); /* initialized = * (2 == sSplit.Length) ? * GetiControl().initialize(sSplit[0], Convert.ToUInt32(sSplit[1]), _username, _password, _proxy_address, _proxy_port, _proxy_user, _proxy_pass, use_https) : * GetiControl().initialize(_hostname, 443, _username, _password, _proxy_address, _proxy_port, _proxy_user, _proxy_pass, use_https); */ } else { initialized = GetiControl().initialize(hostname, port, _username, _password, use_https); /* * initialized = * (2 == sSplit.Length) ? * GetiControl().initialize(sSplit[0], Convert.ToUInt32(sSplit[1]), _username, _password, use_https) : * GetiControl().initialize(_hostname, port, _username, _password, use_https); */ } } } if (initialized) { try { string ver = GetiControl().SystemSystemInfo.get_version(); WriteObject(true, false); } catch (Exception ex) { handleException(ex); } } else { handleError("Could not initialize connection with supplied information", _hostname); } } }
private void DoConnect() { if (!DoDisconnect()) { //ConnectionDialog cd = new ConnectionDialog(); iControl.Dialogs.ConnectionDialog cd = new iControl.Dialogs.ConnectionDialog(); cd.ConnectionInfo = Clients.ConnectionInfo; cd.centerX = this.Location.X + (this.Width / 2); cd.centerY = this.Location.Y + (this.Height / 2); DialogResult dr = cd.ShowDialog(this); if (DialogResult.OK == dr) { Clients.initialize(); if (Clients.Connected) { toolStripMenuItem_FileConnect.Text = "Dis&connect"; toolStripButton_Connect.Image = global::iRuler.Properties.Resources.ToolbarDisconnect; toolStripButton_Connect.Text = "Disconnect. Click the Connect button..."; statusStripLabel_Connection.Text = "Connected to " + Clients.ConnectionInfo.hostname; setStatus(statusStripLabel_Connection.Text, getStatusVisible()); updatePartitionInfo(); //updateFolderInfo(); refreshiRules(); showButtons(true); updateTitle(false); } } else { setStatus("The host you have specified must be a v9.x BIG-IP", true); } } }