So here we have what I believe to be a better work around follow the below steps and all should make sense:
- Allow Anonymous Access on a Central Administration Level. (Central Admin - Authentication Providers - Select Provider in Appriate Web Application - Tick "Enable Anonymous Access")
- Now enable access to "Lists and Libraries" for anonymous access within the site collection. (Site Actions - Site Settings - Advanced Permissions - Setttings - Anonymous Access)
- Now create an InfoPath form, the important part here is to get it to run custom code on submit. It will run a few clever lines of code that will place the InfoPath form in the Document/Form Library.
- Once you have this event open in edit mode craft the below to fit in with your system.
public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
// If the submit operation is successful, set
// e.CancelableArgs.Cancel = False
// Write your code here.
//-----------------------------------------------------------------'
//URL to place the file at, include Site URL, Doc Lib and File Name'
//-----------------------------------------------------------------'
string url = "http://sharepoint2007/TestForm/testing.xml";
//---------------'
//Create XPathNav'
//---------------'
XPath.XPathNavigator xPathNav = this.CreateNavigator();
//---------------------------------------------'
//Convert underlying InfoPath XML to byte array'
//---------------------------------------------'
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] Data = encoding.GetBytes(xPathNav.OuterXml);
try {
//--------------------------------------------------'
//Create webclient, set credentials and upload data.'
//--------------------------------------------------'
WebClient webclient = new WebClient();
webclient.UseDefaultCredentials = new NetworkCredential("USER", "PASS", "DOMAIN");
webclient.UploadData(url, "PUT", Data);
}
catch (Exception ex) {
}
}
Once this has been done, publish the form, follow the steps upload to sharepoint etc. I think the above code quite clearly shows just how easy submitting forms anonymously in SharePoint can be made, a small piece of managed code in an InfoPath Form and happy days.