locked
Problem provisioning the site with unique permissions RRS feed

  • Question

  • Hello,

    I am not able to create a meeting workspace with unique permissions.

    Scenario:

    On site creation event, I am modifying the site and add a list with unique role inheritance. Site creation fails if create site with unique permissions but works with inherit permissions. Code runs with elevated privileges. Error occur after event complete code execution. So, I don't get any exception in visual studio during debugging.

    Code sample to add list to site:

    Guid listId = elevatedWeb.Lists.Add(locaListName, locaListDesc, SPListTemplateType.DocumentLibrary);
                                        list = elevatedWeb.Lists[listId];                                    
                                        list.BreakRoleInheritance(false); //cause problem when site created with unique permissions                                    list.Update();

    Error from SP log:

    System.ArgumentException: Value does not fall within the expected range.    
    at Microsoft.SharePoint.SPListCollection.ItemByInternalName(String strInternalName, Boolean bThrowException)     
    at Microsoft.SharePoint.SPWeb.SyncNewLists()     
    at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate)     
    at Microsoft.SharePoint.ApplicationPages.TemplatePickerUtil.ApplyWebTemplateAndRedirect(SPWeb Web, String strWebTemplate, Nullable`1 bSharedNav, Boolean bOnTopNav, Boolean bOnQuickLaunch, Page page, Boolean bDeleteOnError)     at Microsoft.SharePoint.ApplicationPages.TemplatePickPage.BtnSubmit_Click(Object sender, EventArgs e)     at System.Web.UI.WebControls.Button.OnClick(EventArgs e)     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    Appreciate your help on this.

    Thanks,

    Rajan


    Cheers,
    Rajan
    My Blog: http://rajangarg.wordpress.com/
    SharePoint 2010 Document Converter
    Visual Studio 2010 Solution Export Import Add-in

    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

    Thursday, November 29, 2012 11:31 AM

All replies

  • Hey, 

    would you please post the code where you create the elevatedWeb aswell? From my point of view this should be working just find and trying those lines in my environment worked like a charm.

    Thursday, November 29, 2012 12:55 PM
  • Hello Andreas,

    Thanks for your reply.

    I hope you written your test code based on following flow. And I assume you are trying with Site owner permissions not system account.

    1. Create a feature and attach to Meeeting Workspace (MWS) site template. Activate this feature on M WS site creation. Feature runs with elevated privileges and create a list with unique permissions. Here is feature activation code.

    SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite eSite = new SPSite(web.Site.ID)) { using (SPWeb elevatedWeb = eSite.OpenWeb(web.ID)) { SPList list = elevatedWeb.Lists.TryGetList(locaListName); if (list == null) { Guid listId = elevatedWeb.Lists.Add(locaListName, locaListDesc, SPListTemplateType.DocumentLibrary); list = elevatedWeb.Lists[listId]; list.BreakRoleInheritance(false); //cause problem when site created with unique permissions

    list.Update(); }

    elevatedWeb.Update(); } } });


    2. Try to create the MWS with unique permissions from Calendar. Make sure you logged in a owner not as SC/farm administrator.

    Steps: Goto Calendar -> Create New Event -> Mark checkbox to create MWS -> Provide name of MWS and Select Unique permissions radio button. -> Click Ok -> Select Template from Gallery which has our custom featured attached. -> Clock Ok. Site creation should fail now

    Thanks,

    Rajan 


    Cheers,
    Rajan
    My Blog: http://rajangarg.wordpress.com/
    SharePoint 2010 Document Converter
    Visual Studio 2010 Solution Export Import Add-in

    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

    Friday, November 30, 2012 2:55 AM
  • Hey Rajan, 

    to be totally honest with you, I don't have the time to follow all the steps to confirm the behavior you're describing. From my point of view the code you posted should be working fine. The only thing you could try would be to first call the list.Update() method and getting the list again to break the role inheritance. Separately those 2 things should be working fine, maybe together they cause an exception, but that's just a wild guess. Can't provide you more, sorry.

    Friday, November 30, 2012 8:49 AM
  • Hello Andreas,

    I already tried that. It didn't work out.

    Funny thing with SharePoint is that if I try the 2nd step create MWS site from New Site option. SharePoint creates the site and then delete it because of feature one issue. Also no information in log. With Calendar, MWS provision fails but it still create the partial site in database.

    Thanks for your help.

    Cheers!!!

    Rajan


    Cheers,
    Rajan
    My Blog: http://rajangarg.wordpress.com/
    SharePoint 2010 Document Converter
    Visual Studio 2010 Solution Export Import Add-in

    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

    Friday, November 30, 2012 9:25 AM
  • Hi Rajan,

     I am getting same issue. Any idea how can we solve this ?


    Thanks, Ali Yasir http://www.sharepointstack.blogspot.in/

    Thursday, January 24, 2013 11:49 AM
  • Hi Ali,

    Could you please post your code here. So, it will be easy to find the issue.

    Cheers,

    Rajan


    Cheers,
    Rajan
    My Blog: http://rajangarg.wordpress.com/
    SharePoint 2010 Document Converter
    Visual Studio 2010 Solution Export Import Add-in

    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

    Thursday, January 24, 2013 12:00 PM