コード例 #1
0
 void OnCreateRole(object sender, EventArgs e)
 {
     using (RoleManagerProxy roleManager = new RoleManagerProxy(m_Url))
     {
         string[]           roles  = roleManager.GetAllRoles(m_Application);
         Predicate <string> exists = delegate(string role)
         {
             return(role == m_RoleTextBox.Text);
         };
         if (Array.Exists(roles, exists))
         {
             m_RoleValidator.SetError(m_RoleTextBox, "Role already exists");
             return;
         }
         m_RoleValidator.Clear();
         if (m_RoleTextBox.Text == String.Empty)
         {
             m_RoleValidator.SetError(m_RoleTextBox, "Role cannot be empty");
             return;
         }
         m_RoleValidator.Clear();
         roleManager.CreateRole(m_Application, m_RoleTextBox.Text);
         m_Roles.Add(m_RoleTextBox.Text);
         m_CreatedRolesListView.AddItem(m_RoleTextBox.Text, true);
         m_RoleTextBox.Focus();
         m_RoleTextBox.Text = String.Empty;
     }
 }
コード例 #2
0
      public AuthorizationDialog(string url,string application,string user) : this()
      {
         m_Url = url;
         m_ApplicationTextBox.Text = application;
         m_UserComboBox.Text = user;

         using(RoleManagerProxy roleManager = new RoleManagerProxy(url))
         {
            string[] roles = roleManager.GetAllRoles(application);

            m_RoleComboBox.Items.AddRange(roles);
            if(roles.Length > 0)
            {
               m_RoleComboBox.Text = roles[roles.Length-1];
            }

            using(MembershipManagerProxy membershipManager = new MembershipManagerProxy(url))
            {

               string[] users = membershipManager.GetAllUsers(application);

               m_UserComboBox.Items.AddRange(users);
               if(users.Length > 0)
               {
                  m_UserComboBox.Text = users[users.Length-1];
               }
            }
         }
      }
コード例 #3
0
        public AuthorizationDialog(string url, string application, string user) : this()
        {
            m_Url = url;
            m_ApplicationTextBox.Text = application;
            m_UserComboBox.Text       = user;

            using (RoleManagerProxy roleManager = new RoleManagerProxy(url))
            {
                string[] roles = roleManager.GetAllRoles(application);

                m_RoleComboBox.Items.AddRange(roles);
                if (roles.Length > 0)
                {
                    m_RoleComboBox.Text = roles[roles.Length - 1];
                }

                using (MembershipManagerProxy membershipManager = new MembershipManagerProxy(url))
                {
                    string[] users = membershipManager.GetAllUsers(application);

                    m_UserComboBox.Items.AddRange(users);
                    if (users.Length > 0)
                    {
                        m_UserComboBox.Text = users[users.Length - 1];
                    }
                }
            }
        }
コード例 #4
0
        void OnRemoveUserFromRole(object sender, EventArgs e)
        {
            string role = m_RolesListView.CurrentListViewItem;

            Debug.Assert(!String.IsNullOrEmpty(role));
            using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
            {
                using (UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
                {
                    Debug.Assert(userManager != null);

                    if (userManager.IsInRole(ApplicationName, UserToAssign, role))
                    {
                        DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from the role " + m_RolesListView.CurrentListViewItem + " ?", "Credentials Manager", MessageBoxButtons.OKCancel);
                        if (result == DialogResult.OK)
                        {
                            roleManager.RemoveUserFromRole(ApplicationName, UserToAssign, role);
                            RefreshRolesForUserComboBox();
                            RefreshUsersForRoleComboBox();
                            RefreshRolePageButtons();
                        }
                    }
                    else
                    {
                        MessageBox.Show("The user " + UserToAssign + " is not a member of the role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #5
0
ファイル: NewRoleDialog.cs プロジェクト: ittray/LocalDemo
      void OnCreateRole(object sender,EventArgs e)
      {
         using(RoleManagerProxy roleManager = new RoleManagerProxy(m_Url))
         {
            string[] roles = roleManager.GetAllRoles(m_Application);

            if(roles.Any(role => role == m_RoleTextBox.Text))
            {
               m_RoleValidator.SetError(m_RoleTextBox,"Role already exists");
               return;
            }
            m_RoleValidator.Clear();
            if(m_RoleTextBox.Text == String.Empty)
            {
               m_RoleValidator.SetError(m_RoleTextBox,"Role cannot be empty");
               return;
            }
            m_RoleValidator.Clear();
            roleManager.CreateRole(m_Application,m_RoleTextBox.Text);
            m_Roles.Add(m_RoleTextBox.Text);
            m_CreatedRolesListView.AddItem(m_RoleTextBox.Text,true);
            m_RoleTextBox.Focus();
            m_RoleTextBox.Text = String.Empty;
         }
      }
コード例 #6
0
        void OnAssignUserToRole(object sender, EventArgs e)
        {
            using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
            {
                using (UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
                {
                    Debug.Assert(userManager != null);

                    string role = m_RolesListView.CurrentListViewItem;
                    Debug.Assert(role != String.Empty);

                    if (userManager.IsInRole(ApplicationName, UserToAssign, role))
                    {
                        MessageBox.Show("The user " + UserToAssign + " is already a member of the role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else
                    {
                        roleManager.AddUserToRole(ApplicationName, UserToAssign, m_RolesListView.CurrentListViewItem);
                        RefreshRolesForUserComboBox();
                        RefreshUsersForRoleComboBox();
                        RefreshRolePageButtons();
                    }
                }
            }
        }
コード例 #7
0
 void RefreshRolesForUserComboBox()
 {
     string[] roles = null;
     if (String.IsNullOrEmpty(UserToAssign) == false)
     {
         using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
             roles = roleManager.GetRolesForUser(ApplicationName, UserToAssign);
     }
     m_RolesForUserComboBox.RefreshComboBox(UserToAssign, roles);
 }
コード例 #8
0
        void RefreshUsersForRoleComboBox()
        {
            string[] users = null;

            if (String.IsNullOrEmpty(RoleName) == false)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                    users = roleManager.GetUsersInRole(ApplicationName, RoleName);
            }
            m_UsersInRoleComboBox.RefreshComboBox(RoleName, users);
        }
コード例 #9
0
 void RefreshRolesListView()
 {
     m_RolesListView.ClearItems();
     if (ApplicationName == String.Empty)
     {
         return;
     }
     using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
     {
         string[] roles = roleManager.GetAllRoles(ApplicationName);
         m_RolesListView.AddItems(roles, true);
     }
 }
コード例 #10
0
        void OnDeleteAllRoles(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete all roles from the application?", "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    roleManager.DeleteAllRoles(ApplicationName, m_ThrowIfPopulatedCheckBox.Checked);
                }
                m_RolesListView.ClearItems();
                RefreshUsersForRoleComboBox();
                RefreshRolesForUserComboBox();
                RefreshRolePageButtons();
            }
        }
コード例 #11
0
        void OnRemoveUsersFromAllRoles(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from all its roles?", "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    string[] roles = roleManager.GetRolesForUser(ApplicationName, UserToAssign);
                    if (roles.Length > 0)
                    {
                        roleManager.RemoveUserFromRoles(ApplicationName, UserToAssign, roles);
                        RefreshRolesForUserComboBox();
                        RefreshUsersForRoleComboBox();
                        RefreshRolePageButtons();
                    }
                }
            }
        }
コード例 #12
0
        void OnDeleteRole(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete the role " + RoleName + " ?", "Credentials Manager", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    try
                    {
                        bool deleted = roleManager.DeleteRole(ApplicationName, RoleName, m_ThrowIfPopulatedCheckBox.Checked);
                        if (deleted == false)
                        {
                            MessageBox.Show("Encountered an error trying to delete role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            m_RolesListView.RemoveItem(RoleName);
                            RefreshUsersForRoleComboBox();
                            RefreshRolesForUserComboBox();
                            RefreshRolePageButtons();
                        }
                    }
                    catch (SoapException exception)
                    {
                        if (exception.Message.Contains("This role cannot be deleted because there are users present in it"))
                        {
                            MessageBox.Show("Failed to delete role " + m_RolesListView.CurrentListViewItem + " because it was populated.", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
        }
コード例 #13
0
      void OnAssignUserToRole(object sender,EventArgs e)
      {
         using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
         {
            using(UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
            {
               Debug.Assert(userManager != null);

               string role = m_RolesListView.CurrentListViewItem;
               Debug.Assert(role != String.Empty);

               if(userManager.IsInRole(ApplicationName,UserToAssign,role))
               {
                  MessageBox.Show("The user " + UserToAssign + " is already a member of the role " +  m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                  return;
               }
               else
               {
                  roleManager.AddUserToRole(ApplicationName,UserToAssign,m_RolesListView.CurrentListViewItem);
                  RefreshRolesForUserComboBox();
                  RefreshUsersForRoleComboBox();
                  RefreshRolePageButtons();
               }
            }
         }
      }
コード例 #14
0
 void OnDeleteAllRoles(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to delete all roles from the application?","Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          roleManager.DeleteAllRoles(ApplicationName,m_ThrowIfPopulatedCheckBox.Checked);
       }
       m_RolesListView.ClearItems();
       RefreshUsersForRoleComboBox();
       RefreshRolesForUserComboBox();
       RefreshRolePageButtons();
    }
 }
コード例 #15
0
 void OnRemoveUsersFromAllRoles(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from all its roles?","Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          string[] roles = roleManager.GetRolesForUser(ApplicationName,UserToAssign);
          if(roles.Length > 0)
          {
             roleManager.RemoveUserFromRoles(ApplicationName,UserToAssign,roles);
             RefreshRolesForUserComboBox();
             RefreshUsersForRoleComboBox();
             RefreshRolePageButtons();
          }
       }
    }
 }
コード例 #16
0
 void RefreshRolesListView()
 {
    m_RolesListView.ClearItems();
    if(ApplicationName == String.Empty)
    {
       return;
    }
    using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
    {
       string[] roles = roleManager.GetAllRoles(ApplicationName);
       m_RolesListView.AddItems(roles,true);
    }
 }
コード例 #17
0
 void RefreshRolesForUserComboBox()
 {
    string[] roles = null;
    if(String.IsNullOrEmpty(UserToAssign) == false)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       roles = roleManager.GetRolesForUser(ApplicationName,UserToAssign);
    }
    m_RolesForUserComboBox.RefreshComboBox(UserToAssign,roles);        
 }
コード例 #18
0
 void RefreshUsersForRoleComboBox()
 {
    string[] users = null;
    
    if(String.IsNullOrEmpty(RoleName) == false)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       users = roleManager.GetUsersInRole(ApplicationName,RoleName);
    }
    m_UsersInRoleComboBox.RefreshComboBox(RoleName,users);
 }
コード例 #19
0
 void OnDeleteRole(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to delete the role " + RoleName + " ?","Credentials Manager",MessageBoxButtons.OKCancel);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          try
          {
             bool deleted = roleManager.DeleteRole(ApplicationName,RoleName,m_ThrowIfPopulatedCheckBox.Checked);
             if(deleted == false)
             {
                MessageBox.Show("Encountered an error trying to delete role " + m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Error);
             }
             else
             {
                m_RolesListView.RemoveItem(RoleName);
                RefreshUsersForRoleComboBox();
                RefreshRolesForUserComboBox();
                RefreshRolePageButtons();
             }
          }
          catch(SoapException exception)
          {
             if(exception.Message.Contains("This role cannot be deleted because there are users present in it"))
             {
                MessageBox.Show("Failed to delete role " + m_RolesListView.CurrentListViewItem + " because it was populated.","Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Error);
             }
             else
             {
                throw;
             }
          }
       }
    }
 }
コード例 #20
0
      void OnRemoveUserFromRole(object sender,EventArgs e)
      {
         string role = m_RolesListView.CurrentListViewItem;
         Debug.Assert(! String.IsNullOrEmpty(role));
         using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
         {
            using(UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
            {
               Debug.Assert(userManager != null);

               if(userManager.IsInRole(ApplicationName,UserToAssign,role))
               {
                  DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from the role " +  m_RolesListView.CurrentListViewItem + " ?","Credentials Manager",MessageBoxButtons.OKCancel);
                  if(result == DialogResult.OK)
                  {
                     roleManager.RemoveUserFromRole(ApplicationName,UserToAssign,role);
                     RefreshRolesForUserComboBox();
                     RefreshUsersForRoleComboBox();
                     RefreshRolePageButtons();
                  }
               }
               else
               {
                  MessageBox.Show("The user " + UserToAssign + " is not a member of the role " +  m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
               }
            }
         }
      }