Пример #1
0
 internal bool AccessibleToUser(IPrincipal user)
 {
     return(string.IsNullOrEmpty(this.Roles) || LoginUtil.IsInRoles(user, this.Roles.Split(new char[]
     {
         ','
     })));
 }
Пример #2
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (!base.DesignMode)
     {
         MasterPage master = base.Master;
         while (master != null && this.iMasterPage == null)
         {
             this.iMasterPage = (master as IMasterPage);
             master           = master.Master;
         }
     }
     if (base.Form != null)
     {
         Control contentPlaceHolder = this.ContentPlaceHolder;
         if (contentPlaceHolder != null)
         {
             this.InjectDefaultLayoutControls(contentPlaceHolder);
             this.InitExtenderParameters();
         }
     }
     if (!string.IsNullOrEmpty(this.SetRoles) && !LoginUtil.IsInRoles(this.Context.User, this.SetRoles.Split(new char[]
     {
         ','
     })))
     {
         this.ReadOnly = true;
     }
 }
Пример #3
0
        protected override void OnLoad(EventArgs e)
        {
            string[] roles = new string[]
            {
                "FFO"
            };
            ListView listView = (ListView)this.FindControl("AcceptedDomainsListView");

            if (LoginUtil.IsInRoles(HttpContext.Current.User, roles))
            {
                listView.ShowSearchBar = false;
                return;
            }
            listView.ShowSearchBar = true;
        }
Пример #4
0
        internal static void ApplyRolesFilterRecursive(Control c, IPrincipal currentUser, IVersionable versionableObject)
        {
            IAttributeAccessor attributeAccessor = c as IAttributeAccessor;

            if (attributeAccessor != null)
            {
                string             attribute          = attributeAccessor.GetAttribute("SetRoles");
                string             attribute2         = attributeAccessor.GetAttribute("DataBoundProperty");
                PropertyDefinition propertyDefinition = (versionableObject != null && !string.IsNullOrEmpty(attribute2)) ? versionableObject.ObjectSchema[attribute2] : null;
                if (propertyDefinition != null && !versionableObject.IsPropertyAccessible(propertyDefinition))
                {
                    Properties.HideControl(c, Properties.FindAssociatedLabel(c));
                }
                else if ((!string.IsNullOrEmpty(attribute) && !LoginUtil.IsInRoles(currentUser, attribute.Split(new char[]
                {
                    ','
                }))) || (!string.IsNullOrEmpty(attribute2) && versionableObject != null && versionableObject.IsReadOnly))
                {
                    string attribute3      = attributeAccessor.GetAttribute("NoRoleState");
                    Label  associatedLabel = Properties.FindAssociatedLabel(c);
                    if (!string.IsNullOrEmpty(attribute3) && NoRoleState.Hide == (NoRoleState)Enum.Parse(typeof(NoRoleState), attribute3))
                    {
                        Properties.HideControl(c, associatedLabel);
                    }
                    else
                    {
                        Properties.MakeControlRbacDisabled(c, associatedLabel);
                        if (!string.IsNullOrEmpty(attributeAccessor.GetAttribute("helpId")))
                        {
                            attributeAccessor.SetAttribute("helpId", string.Empty);
                        }
                        attributeAccessor.SetAttribute("MandatoryParam", null);
                    }
                }
            }
            if (c.HasControls())
            {
                foreach (object obj in c.Controls)
                {
                    Control c2 = (Control)obj;
                    Properties.ApplyRolesFilterRecursive(c2, currentUser, versionableObject);
                }
            }
        }
Пример #5
0
 protected override void OnPreRender(EventArgs e)
 {
     this.ResolveServiceUrl();
     base["DataTransferMode"] = this.DataTransferMode;
     if (this.PreLoadData && base.ServiceUrl != null && this.DataTransferMode != DataTransferMode.Collaboration)
     {
         PowerShellResults powerShellResults;
         if (this.ReadOnDemand)
         {
             string workflowName = this.Sections[0].WorkflowName;
             powerShellResults = base.ServiceUrl.GetObjectOnDemand(this.ObjectIdentity, workflowName);
             powerShellResults.UseAsRbacScopeInCurrentHttpContext();
             this.InitialLoadedWorkflow = workflowName;
         }
         else if (this.UseSetObject)
         {
             powerShellResults = base.ServiceUrl.GetObject(this.ObjectIdentity);
             powerShellResults.UseAsRbacScopeInCurrentHttpContext();
         }
         else
         {
             powerShellResults = base.ServiceUrl.GetObjectForNew(this.ObjectIdentity);
         }
         base["PreLoadResults"] = powerShellResults;
     }
     foreach (Section section in this.Sections)
     {
         if (!string.IsNullOrEmpty(section.SetRoles) && !LoginUtil.IsInRoles(this.Context.User, section.SetRoles.Split(new char[]
         {
             ','
         })))
         {
             section.Visible = false;
         }
     }
     base.OnPreRender(e);
 }