示例#1
0
        private void ReadUsers(User currentUser)
        {
            List <UserRow> list;

            if (userNameFilter == null)
            {
                // Query all users
                List <User> source = client.QueryUsers(null);
                list = new List <UserRow>(source.Count);

                foreach (User user in source)
                {
                    list.Add(new UserRow(user));
                }
            }
            else
            {
                // Query own user.
                if (currentUser == null)
                {
                    currentUser = client.QueryUser(null, userNameFilter);
                }
                list = new List <UserRow>(1);

                if (currentUser != null)
                {
                    list.Add(new UserRow(currentUser));
                }
            }

            users = new BindingList <UserRow>(list);
            bindingSourceUsers.DataSource = users;
        }
示例#2
0
        public void getUser()
        {
            // Get username
            string username;

            Console.WriteLine("\nEnter username:"******"\nINFO: User read successfully! Here are the details:\n");
                    Console.WriteLine("roles:     " + string.Join(", ", user.roles));
                }
                else
                {
                    Console.WriteLine("ERROR: User not found!");
                }
            }
            else
            {
                Console.WriteLine("ERROR: User not found!");
            }
        }
示例#3
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;
            }
        }