Пример #1
0
        private void Login()
        {
            int port = int.Parse(portBox.Text.Trim());

            Host[] hosts    = Host.ParseHosts(hostBox.Text.Trim(), tlsName, port);
            string userName = userBox.Text.Trim();
            string password = passwordBox.Text.Trim();

            ClientPolicy policy = new ClientPolicy();

            policy.user               = userName;
            policy.password           = password;
            policy.clusterName        = clusterName;
            policy.failIfNotConnected = true;
            policy.timeout            = 600000;
            policy.tlsPolicy          = tlsPolicy;
            policy.authMode           = authMode;

            AerospikeClient client = new AerospikeClient(policy, hosts);

            try
            {
                if (userName.Equals("admin") && password.Equals("admin"))
                {
                    Form form = new PasswordForm(client, userName);
                    form.ShowDialog();
                }

                // Query own user.
                User user = client.QueryUser(null, userName);

                if (user != null)
                {
                    bool admin = user.roles.Contains("user-admin");

                    // Initialize Global Data
                    Globals.RefreshRoles(client, user, admin);

                    Form form = new AdminForm(client, user, admin);
                    form.Show();
                }
                else
                {
                    throw new Exception("Failed to find user: " + userName);
                }
            }
            catch (Exception)
            {
                client.Close();
                throw;
            }
        }
Пример #2
0
        private void ChangePasswordClicked(object sender, EventArgs e)
        {
            try
            {
                int row = gridUsers.CurrentRow.Index;

                if (row >= 0)
                {
                    Form form = new PasswordForm(client, users[row].name);
                    ShowUserEditForm(form);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void Login()
        {
            string server = hostBox.Text.Trim();
            int port = int.Parse(portBox.Text.Trim());
            string userName = userBox.Text.Trim();
            string password = passwordBox.Text.Trim();

            ClientPolicy policy = new ClientPolicy();
            policy.user = userName;
            policy.password = password;
            policy.failIfNotConnected = true;
            policy.timeout = 600000;

            AerospikeClient client = new AerospikeClient(policy, server, port);

            try
            {
                if (userName.Equals("admin") && password.Equals("admin"))
                {
                    Form form = new PasswordForm(client, userName);
                    form.ShowDialog();
                }

                // Query own user.
                User user = client.QueryUser(null, userName);

                if (user != null)
                {
                    bool admin = user.roles.Contains("user-admin");

                    // Initialize Global Data
                    Globals.RefreshRoles(client, user, admin);

                    Form form = new AdminForm(client, user, admin);
                    form.Show();
                }
                else
                {
                    throw new Exception("Failed to find user: " + userName);
                }
            }
            catch (Exception)
            {
                client.Close();
                throw;
            }
        }
        private void ChangePasswordClicked(object sender, EventArgs e)
        {
            try
            {
                int row = gridUsers.CurrentRow.Index;

                if (row >= 0)
                {
                    Form form = new PasswordForm(client, users[row].name);
                    ShowUserEditForm(form);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }