SP2010: BCS issue; CalculatePermissionsForCurrentThread

This probably is the last post in my latest BCS series for now, since our project is almost finished 🙂 One of the last hurdles I had to take was an error which only occured in our production environment for some reason (I guess production and test still aren’t similar enough). It occurred when trying to get a single BCS entity in code and had something to do with the permissions not being valid.

Here’s the code I used to get the entity:

Ok so that wasn’t working. It was instead giving me this error:

And when running elevated, it changed to:

Ok. So to cut a very long story short: i tried A LOT of different things with permissions, different code snippets, you name it. And after too much time, I finally found the solution. Which is not in the FindSpecific call itself (which you would expect), but much earlier when retrieving the metadata catalog. I’m now using the following method:

I’m sorry I can’t really clarify what’s the difference between the two (they receive the same catalog as far as I know), but the second one works. One little tip: you probably do need to run this elevated because your normal user won’t have enough rights in the BCS app to query the model / services like this (if it does; it really shouldn’t).

Leave a Reply

Your email address will not be published. Required fields are marked *