コード例 #1
0
        private void ReplaceRoles(string user, List <string> roles)
        {
            // Find grants.
            List <string> grantRoles = new List <string>();

            foreach (string role in roles)
            {
                if (!FindRole(oldRoles, role))
                {
                    grantRoles.Add(role);
                }
            }

            // Find revokes.
            List <string> revokeRoles = new List <string>();

            foreach (string oldRole in oldRoles)
            {
                if (!FindRole(roles, oldRole))
                {
                    revokeRoles.Add(oldRole);
                }
            }

            if (grantRoles.Count > 0)
            {
                client.GrantRoles(null, user, grantRoles);
            }

            if (revokeRoles.Count > 0)
            {
                client.RevokeRoles(null, user, revokeRoles);
            }
        }
コード例 #2
0
        public void revokeRole()
        {
            Console.WriteLine("\n********** Revoke Role **********\n");

            string username;
            string role;

            // Get username
            Console.WriteLine("Enter username: "******"Enter a role to revoke from " + username + ":");
                role = Console.ReadLine();

                string[] roles = { role };
                client.RevokeRoles(null, username, roles);

                Console.WriteLine("\nINFO: Role revoked!");
            }
        }