private SessionDefinition GetSession(Account user) { IDesktopServiceConfiguration config = DesktopServiceConfiguration.Read(); Client client = new Client(config.CloudStackUri); client.Login(user.Name, user.Password, user.Domain, config.HashCloudStackPassword); Console.WriteLine("Logged into Cloudstack as {0}", user.Name); ListVirtualMachines(client); Cookie cookie = FindSessionCookie(client.Cookies); if (cookie == null) { throw new ApplicationException("Failed to acquire session: Could not find session cookie"); } ShowCookie(cookie); Console.WriteLine("Session Key is {0}", client.SessionKey); return new SessionDefinition() { SessionCookie = cookie, SessionKey = client.SessionKey }; }
private void logonToolStripMenuItem_Click(object sender, EventArgs e) { CredentialsForm credentialsForm = new CredentialsForm("User Name", "Password", true, true); DialogResult r = credentialsForm.ShowDialog(); if (r == DialogResult.OK) { try { client = new Client(new Uri(textBoxUrl.Text)); client.Login(credentialsForm.UserName, credentialsForm.Password, credentialsForm.DomainName, credentialsForm.HashPassword); UpdateCurentUser(credentialsForm.UserName); } catch (Exception ex) { WriteToLogBox(ex.ToString()); } } }