Access denied when using RunWithElevatedPrivileges?

Posted by James123 on Stack Overflow See other posts from Stack Overflow or by James123
Published on 2010-06-15T22:03:11Z Indexed on 2010/06/16 7:02 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

I want regular user can access the "User Information List" in Mysite root site. I am using "RunWithElevatedPrivileges" method. Still throwing access denied error. per example my root site collection for mysite is "http://network.test.com". the user want assess userinformation list this site collection. How can he access that?

 SPSecurity.RunWithElevatedPrivileges(delegate
 {
   using (SPSite site = new SPSite(SPContext.Current.Web.Site.ID))
   {

   ServerContext sc = ServerContext.Current;
   UserProfileManager upm = new UserProfileManager(sc);
   UserProfile up = null;
   //get current user's profile (visitor)
   if (upm.UserExists(SPContext.Current.Web.CurrentUser.LoginName))
   {
       up =upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);

      SPWeb web = SPContext.Current.Web;
      SPList userInformationList = web.Lists["User Information List"];

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET