Ejemplo n.º 1
0
        private void BindPermissions()
        {
            Permission.PermissionList perms =
                new Permissions(Globals.CurrentIdentity).GetTypePermissions(GetObjectType());

            int prinID = (int) dgRoles.DataKeys[dgRoles.SelectedIndex];
            Principal prin = new Principals(Globals.CurrentIdentity).GetInfo(prinID);
            lblPrin.Text = "Selection: " + prin.Name;

            dgPerms.DataSource = perms;
            dgPerms.DataBind();
        }
Ejemplo n.º 2
0
        protected void CreatePermissions(int entityID, int courseID, string type)
        {
            CourseRole.CourseRoleList roles = new Courses(m_ident).GetRoles(courseID, null);
            Permissions permda = new Permissions(m_ident);

            //Give actor permission power
            CourseRole mrole = new Courses(m_ident).GetRole(m_ident.Name, courseID, null);
            m_dp.AssignPermission(mrole.PrincipalID, "updateperms", type, entityID);
            foreach (CourseRole role in roles) {
                if (role.Staff) {
                    //Do the rest of the perms
                    Permission.PermissionList perms = permda.GetTypePermissions(type);
                    foreach (Permission perm in perms)
                        permda.Assign(role, type, perm.Name, entityID, courseID);
                }
            }
        }
Ejemplo n.º 3
0
 private void cmdApply_Click(object sender, System.EventArgs e)
 {
     CheckBox chkGrant;
     Permission.GrantType grant;
     string perm, otype = GetObjectType();;
     int prinID = (int) dgRoles.DataKeys[dgRoles.SelectedIndex], oid = GetID();
     int courseID = GetCourseID();
     Permissions permda = new Permissions(Globals.CurrentIdentity);
     foreach (DataGridItem item in dgPerms.Items) {
         perm = (string) dgPerms.DataKeys[item.ItemIndex];
         grant = new Permissions(Globals.CurrentIdentity).CheckPermission(prinID, courseID,
             otype, perm, oid);
         chkGrant = (CheckBox) item.FindControl("chkGrant");
         try {
             if (chkGrant.Checked && grant == Permission.GrantType.DENY)
                 permda.Assign(prinID, otype, perm, oid, courseID);
             else if (!chkGrant.Checked && grant == Permission.GrantType.DIRECT)
                 permda.Deny(prinID, otype, perm, oid, courseID);
         } catch (DataAccessException er) {
             PageError(er.Message);
             break;
         }
     }
     BindPermissions();
 }
Ejemplo n.º 4
0
 private void dgPerms_ItemDataBound(object sender, DataGridItemEventArgs e)
 {
     CheckBox chkGrant;
     if (null != (chkGrant = (CheckBox) e.Item.FindControl("chkGrant"))) {
         int prinID = (int) dgRoles.DataKeys[dgRoles.SelectedIndex];
         Permission perm = e.Item.DataItem as Permission;
         Permission.GrantType grant =
             new Permissions(Globals.CurrentIdentity).CheckPermission(prinID, GetCourseID(),
                 GetObjectType(), perm.Name, GetID());
         switch (grant) {
         case Permission.GrantType.DENY:
             chkGrant.Checked = false;
             break;
         case Permission.GrantType.INHERIT:
             chkGrant.Checked = true;
             chkGrant.Enabled = false;
             break;
         case Permission.GrantType.DIRECT:
             chkGrant.Checked = true;
             break;
         }
     }
 }