Anon InfoPath forms

6 Feb

Been working on a site that requires allowing anonymous users to be able to complete and submit an InfoPath form. The complication here is that the site is externally hosted, so ideally a sandboxed solution should be used. Also, Anonymous users can’t have access to the form list/submitted forms once they’ve completed the form..

I couldn’t find a way to get this working with these restrictions. There seem to be ways to enable anonymous access to post to lists (fudge the admin screen QS from DOCLIB to LIST to allow setting the ‘add’/’edit’ permission) but this forces the view permission, which wasn’t acceptable.

The solution could only be a Farm solution – that way we can RunWithElevatedPrivileges to submit the form and the anonymous user doesn’t get any access rights to the list at all. But it’s all in the InfoPath form really, like this (from memory, without the code in front of me..)

1. Edit the InfoPath form, on the options (‘Advanced Form Options’), edit the ‘Security and Trust’ tab and choose the ‘Full Trust’ security level explicitly.

2. On the ‘Compatability’ tab, ensure the form type is ‘Web Browser Form’ and enter the site url in the server address.

3. On the form, add a submit button, and on the button properties ‘General’ tab, ensure the Action is set to ‘Rules and Custom Code’, then edit the form code.

4. Submit the form in the click event

SPSecurity.RunWithElevatedPrivileges(delegate(){ 
    this.Submit();
});

5. Publish the form. Or wsp if you don’t have rights yourself.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: