Mittwoch, 24. März 2010

BCS - add item form for creator method not working

You have created a BCS model, added a creator method to it but it is throwing an Runtime Error. In the logfile you find "SPException: Unable to find the default new form for list"



A probable reason for that error is the following. You created the model only with a ReadList and ReadItem method. Then you created a list in SharePoint and tested that functionality. Then you added a creator method and used the previous created list to add an item. That does not work because the list was provisioned without the "new form". Just delete the list and create a new one. The "new form" for the list should show up as expected.

Dienstag, 23. März 2010

Access denied. You do not have permission to access this content

You have created an External Content Type in SharePoint Designer 2010 with the authentication mode "User's Identity". When you create a list and want to access the data in your portal, you get the error message "Access denied. You do not have permission to access this content" or "Access denied by Business Data Connectivity".

You need to set permissions in Central Administration under "Manage Service Applications" in the "Business Data Connectivity Service Application". Click the BCS service and configure the permissions in the context menu of your ETC.

Also the user needs permissions in your external database.

Montag, 15. März 2010

Access Denied when using EnsureUser

Sometimes you may need to call spweb.EnsureUser from your custom SharePoint web application. This method edits the user permissions on the site and needs some high level permissions like the site collection admin has.
If the user is a "Contributor" or "Reader", he will get the standard sharepoint "Error: Access Denied" message. Your EnsureUser API call has to be wrapped within RunWithElevatedPrivileges. But if you use instances of SPSite or SPWeb, obtained prior to the RunWithElevatedPrivileges block, it won't work as expected because they are already associated to a non-elevated security context.
In the RunWithElevatedPrivileges code block you have to create a new SPSite object simply with the GUID that you get from the previously obtained site.ID.