Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am building a site where users have Contribute access. They are allowed to add, modify, remove items in any of the lists, but they are not allowed to change or remove the lists. However, they also need to be allowed to create new survey lists.

I'm leaning toward creating a custom page or web part that users in the Members group can access. Based on their entries, I can create the list with SPSite.SystemAccount and then grant the Members group Full Control on the list.

Any better ideas?

ManageLists is too broad. Can I create a permission level that only grants the ability to create lists? Or can I limit list management to a certain template?


Solution:

In the end, I created a customized version of new.aspx. Not only did I want to maintain the same UI, but by looking at the "documentation" for NewListPage, I found that the trick, especially for a survey, is using CreateListFromRpc:

protected void BtnOk_Click(object sender, EventArgs args)
{
    NameValueCollection queryString = this.Request.Form;
    Uri nextUrl;
    SPSite site = this.Web.Site;
    Guid id = this.Web.ID;
    SPUtility.ValidateFormDigest();
    using (SPSite systemSite = new SPSite(site.ID, site.SystemAccount.UserToken))
    {
        using (SPWeb web = systemSite.OpenWeb(id))
        {
            SPList listFromRpc = web.Lists.CreateListFromRpc(queryString, out nextUrl);
            SecureItem(web, web.AssociatedMemberGroup, listFromRpc, SPRoleType.Administrator);
        }
    }
    string str2 = "Ribbon.List";
    string str3 = "WSSListAndLibrary";
    string str4 = nextUrl.ToString();
    if (this.Web.UIVersion > 3)
        str4 = AppendQueryStringParameterToUrl(AppendQueryStringParameterToUrl(str4, "InitialTabId", str2), "VisibilityContext", str3);
    SPUtility.Redirect(str4, SPRedirectFlags.Default, this.Context);
}

Thanks to the reminder from @Vamsi that this page should not be in the layouts, I put this page in a feature, which I provisioned as follows:

<Module Name="Survey" Path="Modules">
    <File Url="NewSurvey.aspx" Type="Ghostable" />
</Module>
<CustomAction 
    Id="ContributorNewSurvey" 
    GroupId="SiteActions" 
    Location="Microsoft.SharePoint.StandardMenu" 
    Title="New Survey"
    Description="Create a list of questions which you would like to have people answer."
    ImageUrl="/_layouts/images/Survey.png"
    Rights="AddListItems"
    Sequence="225">
        <UrlAction Url="~site/newsurvey.aspx"/>
</CustomAction>
share
    
Add your solution as an answer and mark it the correct answer. –  Mike Aug 15 '12 at 16:21
1  
@Mike: The answer and comments from Varnsi are what led me to my implementation. I did not want to take away credit for what is the correct answer based on additional details I found during implementation. –  Rich Bennema Aug 15 '12 at 16:38

2 Answers 2

up vote 1 down vote accepted

I have not tried this but Just a thought :)

  • Create a custom list as request center for Survey Lists creation, let the contributors add the request here
  • For the Site Owner/Admin; Create a Page with Content Editor Webpart which runs the Client Object Model to list all the requests and provide a button "Create" , when clicked will create a list as it runs with Owner Privileges.

This adds one more step but can be treated as Review :)

share
    
I like that idea. But instead of making it a 2-step workflow, I would add an ItemAdding event receiver that would create the list using the System Account, grant the user Full Control on the list, and then redirect the user to the create questions page. Creating a custom list might be easier than creating a custom version of _layouts/new.aspx –  Rich Bennema Sep 1 '11 at 12:51
    
My idea was to avoid server side cold deployment, but if complete automation is the goal then custom code is must. IMHO we should try our best not to touch _layouts application pages as there are common resources. –  Vamsi Sep 1 '11 at 20:30
    
There is already a custom solution package to create and configure this site, so adding this is no problem. And, yes, it should be as automated as All Site Content > Create > New Survey. A contributor who has Manage Lists permissions in other sites should notice little or no difference in how a survey is created in this site. –  Rich Bennema Sep 1 '11 at 20:39
    
And I agree that OOTB files in the 14 hive should be touched. That is why I would create a custom version named newsurvey.aspx and placed into a new directory under Layouts. –  Rich Bennema Sep 1 '11 at 20:41
1  
I think you might have guessed this already :) In this case any contributor in the whole farm in any site can create survey list, so just be careful when u add stuff to layouts. I would prefer to make the solution feature depended, meaning like when the feature activated then the contributors can create survey lists. –  Vamsi Sep 1 '11 at 20:51

I would create a custom webpart with a form for list creation. The list creation can be run within RunWithElevatedPrivileges or through impersonation of a user who has the permissions to create lists.

share

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .