Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Impersonation In SharePoint...

  Asked By: Amie    Date: Apr 02    Category: Sharepoint    Views: 1152

I am writing some code that seems to fuss about the permissions that
both the anonymous and authenticated user have (or don't have for
that matter).

I have read a number of blog entries, some of which recommend you use
SPSecurity.RunWithElevatedPriveleges and some of which recommend you
use impersonation instead of SPSecurity.RunWithElevatedPriveleges.

I am trying to use impersonation but I am not having much luck. When
using impersonation, I believe I need to get a SPUserToken object to
pass into the SPSite constructor. Everything I have tried fails with
SharePoint fussing about permissions. From a very brief look, it
looks like SPSecurity.RunWithElevatedPriveleges might work but I may
run into probelems down the road.

The first question is whether or not
SPSecurity.RunWithElevatedPriveleges is the only way to get done what
I need to get done. The second question is what might I be missing.
Are there any code samples? The code will need to run in the context
of an anonymous user or a user that has little to no permissions.



1 Answer Found

Answer #1    Answered By: Kaila Hahn     Answered On: Apr 02

Your code  is making an update on behalf of a user  that does not have permission?
If so, look  at my ImageUploadWebPart on

The web part uses RWEP. However, impersonation  via the system account is a
better way. Changing the part is on my to-do list, as is a whitepaper discussing
the trade-offs. While you're waiting for me to get that stuff done, review blog<http://daniellarson.spaces.live.com/>.

Didn't find what you were looking for? Find more on Impersonation In SharePoint... Or get search suggestion and latest updates.