Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

RunWithElevatedPrivileges and SPGroup.ContainsCurrentUser

  Asked By: Conor    Date: Apr 23    Category: Sharepoint    Views: 2714

I have experienced an issue with SPGroup's ContainsCurrentUser method
when call within the RunWithElevatedPrivileges context.

I know it is necessary to instantiate all objects within the elevated
context and in creating the SPGroup within the code block I thought
everything was proper, but I would not get the expected result when
using the ContainsCurrentUser call. Is that method call unusable
within the elevated block?



1 Answer Found

Answer #1    Answered By: Ivy Salinas     Answered On: Apr 23

The problem is that when you run code  with Elevated privileges it switches out
the user identity running the thread from the current user to the app pool
identity account. So when you call  ContainsCurrentUser its not processing the
user you think it is. Its processing the app pool identity account instead.

Didn't find what you were looking for? Find more on RunWithElevatedPrivileges and SPGroup.ContainsCurrentUser Or get search suggestion and latest updates.