Пример #1
0
        // <Snippet1>
        private void DataRepeater1_DeletingItems(object sender,
                                                 Microsoft.VisualBasic.PowerPacks.DataRepeaterAddRemoveItemsCancelEventArgs e)
        {
            // Check whether the user is a supervisor.

            ClientRolePrincipal rolePrincipal =
                System.Threading.Thread.CurrentPrincipal
                as ClientRolePrincipal;

            if (rolePrincipal.IsInRole("supervisor") == false)
            {
                e.Cancel = true;
                MessageBox.Show("You are not authorized to delete.");
            }
        }
Пример #2
0
        //<snippet313>
        private void DisplayButtonForManagerRole()
        {
            try
            {
                ClientRolePrincipal rolePrincipal =
                    System.Threading.Thread.CurrentPrincipal
                    as ClientRolePrincipal;

                if (rolePrincipal != null && rolePrincipal.IsInRole("manager"))
                {
                    managerOnlyButton.Visible = true;
                }
            }
            catch (System.Net.WebException)
            {
                MessageBox.Show("Unable to access the roles service.",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }