You must Sign In to post a response.
  • Category: Sharepoint

    Access Denied Error in SharePoint

    Hi Friends,

    I have written below code to create a dynamic control ; its working fine for site admin , contribute permissions users ... however its giving access denied error for visitor groups ? any idea and solution ? i tried with elevated privileges and Catchaccess denied exception , still no luck...

    erroring in this line this.Controls.Add(this.htmlEditor);

    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
    bool originalCatchValue = SPSecurity.CatchAccessDeniedException;
    SPSecurity.CatchAccessDeniedException = false;
    SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
    if (ribbon != null)
    {
    ribbon.TrimById("Ribbon.EditingTools.CPEditTab.Layout");
    ribbon.TrimById("Ribbon.EditingTools.CPEditTab.EditAndCheckout");
    }
    this.htmlEditor.Field = new RichHtmlField();
    this.htmlEditor.Field.ControlMode = SPControlMode.Edit;
    this.htmlEditor.Field.EnableViewState = true;
    this.htmlEditor.Field.AllowReusableContent = false;
    this.htmlEditor.Field.MinimumEditHeight = this.MinimumEditHeight;
    this.htmlEditor.Field.PopupEditorMode = true;
    this.htmlEditor.Field.HasInitialFocus = true;
    this.htmlEditor.Field.UseInlineStyle = true;
    this.Controls.Add(this.htmlEditor); // access denied error for visitors but it works for contribute permission users
    base.OnInit(e);
    SPSecurity.CatchAccessDeniedException = originalCatchValue;
    });
    Thanks,
    Kiran
  • #754892
    Hi,

    I think you don't have an access to create a new control. Recheck the configurations settings and check whether you have access for the same or not.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #754960
    am using SPSecurity.RunWithElevatedPrivileges(delegate()
    {
    }

    still why this error ?


  • Sign In to post your comments