SPSecurity.RunWithElevatedPrivileges Not Working for Read Only Permissions Users

I have the following code in a method that generates tabbed web parts on any page in SharePoint 2010.
The problem is that it will not work for users who have Read access only on a SharePoint site.  It will work when those users have Contribute access.  
So even though I have elevated permissions in the code it does not actually elevate the permissions at the point where it is needed.
if (panel != null)
try
using (SPLimitedWebPartManager wpManager = SPContext.Current.Web.GetLimitedWebPartManager(HttpContext.Current.Request.Url.ToString(), PersonalizationScope.Shared))
try
// Elevated previleges required for EXPORT and IMPORT. Else Users with normal read access will get errors.
SPSecurity.RunWithElevatedPrivileges(delegate()
// Retrieve the web part titles in the ConfigureTabs XML string for this tab.
var webPartTitles = from t in xDocument.Descendants("webPart")
where (string)t.Parent.Attribute("name") == (string)e.Item.DataItem
select (string)t.Attribute("title");
foreach (string wpTitle in webPartTitles)
foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in wpManager.WebParts)
// Find the matched closed web part in WebParts collection
if (webPart.Title == wpTitle && webPart.IsClosed == true)
string errorMessage;
//ADD EXPORT PROPERTY
webPart.ExportMode = WebPartExportMode.All;
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
// Export the closed webpart to a memory stream.
wpManager.ExportWebPart(webPart, writer);
writer.Flush();
stream.Position = 0;
XmlTextReader reader = new XmlTextReader(stream);
// Import the exported webpart.
System.Web.UI.WebControls.WebParts.WebPart newWebPart = wpManager.ImportWebPart(reader, out errorMessage);
reader.Close();
writer.Close();
// Show the imported webpart.
panel.Controls.Add(newWebPart);
break;
catch (Exception ex)
// For debugging use only.
Label label = new Label();
label.Text = "Please check your XML configuration for error. " + Environment.NewLine + ex.Message;
panel.Controls.Add(label);
catch (Exception ex)
// For debugging use only.
Label label = new Label();
label.Text = "Please Check SPContext.Current.Web is not null. " + Environment.NewLine + ex.Message;
panel.Controls.Add(label);
This snippet of code was originally pulled from a microsoft technet article on creating Tabbed web parts "the correct way" but it doesn't work in all scenarios.
Is there a way to get this code working for Read/Visitors to a SharePoint site?

From initial observation what I see is that your SPLimitedWebPartManager is not created from an elevated web. Try like below
SPSecurity.RunWithElevatedPrivileges(delegate()
using(SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID))
using(SPWeb elevatedWeb = elevatedSite.OpenWeb())
using (SPLimitedWebPartManager wpManager = elevatedWeb.GetLimitedWebPartManager(HttpContext.Current.Request.Url.ToString(), PersonalizationScope.Shared))
{ //Rest of your code
Geetanjali Arora | My blogs |

Similar Messages

  • Style Code Not Working for Read Only Users !

    Hi 
    Can anyone help us with this issue. We have created some special Styling code in order to hid the Quick Launch on the home page of our main SharePoint site. The Styling works no problem at
    all for users with edit rights, however we found that the styling did not work for users with read only access.  What we found was that if we switched on the "Edit Items  -  Edit items in lists, edit documents in document libraries, and
    customize Web Part Pages in document libraries." in the List Permissions for the Permission Levels for the Read Access group, the Styling then works no problem at all. HOWEVER it then gives those users the ability to EDIT the site page, as it then
    puts the Edit option on the page top right for the user to click and then mess up the web page, which we can not permit. 
    SO..... How do we get this styling to work for ALL user types ?

    Hi,
    This usually happens when the CSS file is not published or approved, please check it.
    If the CSS files uploaded in the Style Library, please check whether you had to check in those CSS files or not.
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint 2010 List View Web Part not showing for read-only users?

    Hello all,
    I have List View Webparts on my Blank Web Part page, and it's not showing for Read-Only users.
    Is this intended by Microsoft or is it a bug?
    Thank you!

    Hi,
    According to your post, my understanding is that the read only user could not see the list view web part.
    Per my knowledge, the issue may be cause that the user do not have the proper permission for the list.
    1. Check whether the user can access the list.
    2. Check whether the user can view all the items instead of partial items in the list.
    3. Check whether there are some fields refer to other lists or terms, especially the lookup field or managed metadata filed.
         If that is the case, make sure the user can access the lookup list.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • This operation is not available for read only field 'Type MVF'

    Hi All,
    We are using OrderToCash PIP and we are on Siebel 8.1X.
    While Synching the customer from Ebiz to Siebel facing the following issues:
    Method 'WriteRecord' of business component 'Account' (integration component 'Account') for record with search specification '[Row Id] = "2d3434313239353"' returned the following error:"This operation is not available for read only field 'Type MVF'.(SBL-DAT-00402)"(SBL-EAI-04451)
    Please suggest us what steps to be done in Siebel.
    Thanks
    Maanasa

    First check the process why this is calling Account BC WriteRecord(). The field "Type MVF" might be read only and this sync process is trying to update this field which is read only. This is the reason for the error. Check the OM log / EAI Obj Manager Comp log (set log level to 5) and check.
    Joseph Arul Dass

  • Enter event not triggering for read-only checkbox

    I have some objects in a form that get "locked" when the user signs the form.  I'm not using the digital signatures.  Instead, when the user types their name into the signature text field, a script runs on the change event that makes all of the fields in the form read only.  It also unlocks the fields if the signature is deleted.
    I was worried that we would get a lot of phone calls with users that didn't understand that the form had locked ("Why doesn't this form work?!"), so I added some code to the enter event for all of the fields that would pop up a messagebox to explain to people trying to edit a signed form that the form was locked and that they would need to delete the signature to edit the form.
    This plan works perfect for my text fields and decimal fields.  It does NOT work at all for my checkboxes.  For some reason, the enter event is never triggered for read-only checkboxes.  I don't see any other events that would obviously work for me though.  Any ideas?
    Thanks

    Thanks, those are reasonable suggestions.
    In the first suggestion, I'm unclear about one aspect of how I would accomplish this.  I assume I would allow people to modify fields in the form, but that when they did, a msgbox would pop up that would inform them that, if they continued with this modification to a signed form, the signature would be removed.  I'm all good to that point.  But if they answered that they do not want to continue modifying that field and removing the signature, how can I code it to set the value back to what it was before the change?  Is there some method that will give me access to the value of the field BEFORE the attempted modification?  I went looking for something like $.previousvalue, but found nothing.
    I'd suggest that I could use a two-stage solution, in which I store the previous value on the enter event, and save it just in case they do not want to change the field when prompted by the msgbox, but since the enter event does not exist for checkboxes (my original problem), that seems like it won't work.
    As far as radio button suggestion, I like radio buttons very much except for one fatal flaw: they aren't (as far as I can tell) clearable.  That is a shame.  Clearly some people (like me) want both exclusivity AND clearability.  And we'd like the controls to have an enter event.  But I know I'm demanding   Anyway, as it is, I just end up having to use checkboxes and create a boatload of silly code to make them exclusive.
    Emily

  • Speakers not working for Skype only on Windows 8.1

    My speakers or headphones are not working for Skype desktop but work fine for any music or videos or other programms. Any help to resolve it? in Tools>Options>Audio Settings> headphones does not show up. Everything was working fine but it just happend a day before., i havent installed any program that could make problem.

    This is very strange because, as you are saying this happened without any change to any software on your computer. I suggest the following:
    1. To help the team analyze the issue, provide logs as described in this link  under Skype for Windows Desktop and attach it to your post.
    2. As an interim solution you can try using a virtual audio device that will be a middle man between skype and your physical audio device.

  • DBMS - Data not visible to read only account users.

    I have created below view to know the status of my batch jobs which run on server every sunday.
    CREATE OR REPLACE VIEW CAFDB_REFRESH AS
    SELECT
    log_id,
    owner,
    to_char(log_date, 'DD-MON-YY HH24:MI:SS') TIMESTAMP,
    job_name,
    status,
    ERROR#,
    run_duration,
    instance_id,
    additional_info
    FROM user_scheduler_job_run_details;
    it is working fine and i am able to get the information.
    now to make it visible to read only account users - using "grant select " i have given access and also created public synonym.
    but it is showing only column names in read only account not the data.
    how to make this visible to read only account?
    please guide.

    USER_ views will only have the objects owned by the user running the query..In your case it will have only the schedules done by the user.
    You will have to ue ALL_ or DBA view (all_scheduler_job_run_details)

  • FormsCentral PDFs not working for Linux and Unix users

    I recently created a PDF (using Indesign > Acrobat IX Pro > Formscentral [AFC]) that includes radio buttons, form fields, linked videos set to play in the PDF once clicked and (after running through AFC) a submit button.
    The form has been distributed and we have already had hundreds of successful responses collected in the AFC site, all is working well there.
    One major problem we are having is that we have a lot of Linux/Unix users and the response from them is that they can't activate the videos, the form fields are out of kilter alignmentwise and the submit button does not work. Even when using the proper Adobe Acrobat Reader (v9, for example).
    Is the Adobe development team aware of problems such as these for Linux/Unix platforms and is there a suggested fix that they know of?
    The link to the actual file is here: http://cms.iopscience.iop.org/alfresco/d/d/workspace/SpacesStore/b5a48eac-8642-11e2-8cf8-e 50acbc9fd86/NJP-Video-Abstracts-Competition-2013.pdf
    Thanks in advance

    Hi Jesse,
    can you email me ([email protected]) the original PDF (before you imported it in FormsCentral)? Also, I'm curious about the format of the video in the PDF. Does the video in the PDF worked in Linux/Unix before going through the FormsCentral import/export?
    When I look at your PDF on my Red Hat Entrprise Linux 6.0 system with Reader 9.5.4 it does look fine (location of the fields) but the video generate an error (which I'm still investigating). I have not yet try the submit button on your form (as I don't want to submit bad data to you) but I seem to have an issue with the submit button on other PDF forms I generated (when I try to submit from a linux machine). Still investigating that as well.
    Gen

  • Itunes Equalizer not working for video - only affecting songs

    I have noticed that any Itunes equalizer settings that I select only affect songs in my itunes library. Videos are not affected at all by the equalizer settings. This means if I have a very dull sounding video I cannot use the equalizer to improve the audio. Does anyone know how to make the equalizer affect videos within itunes. Thanks in advance

    Apple does not care. You have already bought their product and that's all that matters... They got your money and they're happy; you don't have to be. Sadly, all you've paid for is a nice logo on the back of what should be an amazing device.
    Only buy an iPod/iPad/iPhone/iDevice if you are trying to impress your friends. Don't buy one if you want to be impressed, because this will not be the case. It will serve no purpose beyond making you look as though you have money to throw away.
    But, since you have already given them your hard-earned money, I suggest you don't use an EQ setting. "Off" works best as it produces the least amount of distortion on the iDevices I've tried.
    Hope this helps and "enjoy" your Apple experience.

  • Acroread -landscape option not working for Reader 8.1.3 - Solaris 10

    OK I've read the other posts in which others are having this issue as well. I'm hoping this has been fixed or someone can tell me what we need to do to get this working. This use to work with Solaris 9/Reader 5 but when we upgraded to Solaris 10/Reader 8 it stopped working. The ps file use to come out in landscape and then printing it was a no brainer. Now the ps file is coming out potrait (ignoring the landscape option). The next step would be to print this via CUPS but it's printing potrait, same as the ps file. Any help would be great. Thanks.
    Solaris 10
    Reader 8.1.3
    acroread -toPostScript -size tabloid -landscape 9780736651325.pdf
    Running the above command produces a 9780736651325.ps file in potrait format and not landscape. It seems to be ignoring the -landscape option. Please help. Thanks.

    OK I emailed you the pdf we were testing with. This works perfectly in Adobe Reader v5. I tried v7.0.9 and it works great from the GUI but not matter what I try I can't get it to save to a ps file correctly from the command line using the -toPostScript options like -landscape and -shrink (although with v5 we don't need to use these sub-options). I also tried 8.1.2 and 8.1.3 and can't get it to print to the ps file correctly in landscape from either the GUI or the command-line. Not sure wht the magic combination is. The ps file should look just like the pdf file. For now we've gone back to Reader v5 since it works but we wanted to use the latest and greatest. Thanks.

  • M177fw wireless not working for scanner only-have same printer in second location

    I have this exact same MFP laserjet in another location that works perfectly over the wifi network.  I just purchased the same printer for a second physical location and installed it.  I gave the new printer a different name when I installed the device.  Printing over wifi works perfectly from two laptops.  The copy function works perfectly.  I cannot get the scanner to work at the new location from either laptop.
    When I installed the software on one of the laptops, I got a message that the driver was already present and suggested I use the existing version already installed.   So I used the already installed software.  For this laptop, I have a shortcut from the start menu called HP Scan.  At the original location, this works fine over wifi.  For the new printer at the new location, when I start HP Scan from either the HP folder or the shortcut, I get a box titled "Scanner Unreachable.  Scanner communication cannot be established..."  and suggests updating the IP address.  I looked at the printer configuration and the ip address is correct.  
    I reset the printer to the factory settings, rebooted the modem and configured the printer again, hoping that the correct IP address would populate correctly, but I have the same problem.  So my questions are:
    -Is it likely that the IP address is the problem for the scanner and how do I fix it?
    -If it is the IP address, what can I do to not have to manually change it each time I go to a different location?
    -If not, what is the likely problem?  What can I do to fix it?

    Hi,
    As you mention "When I installed the software on one of the laptops, I got a message that the driver was already present and suggested I use the existing version already installed.", such a message is common for adding a printer from the Windows Add a Printer wizard, may you added it by clicking add printer under Devices and Printers?
    If so, that may explain the issue as the printer should be added via the HP Software for the HP Scan to operate.
    Be sure to remove the newly added device first by right clicking it and selecting Remove Device, then reboot your PC.
    From the Start menu select HP and open the printer folder. then select Reconfigure your HP device.
    Follow the steps on screen to add the printer on your current location and check if that may help,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • BUG:text-align:right; inline style not working on read-only af:InputText

    Hello,
    A bug in how af:InputText works if readonly=true. I have an af:InputText that has "text-align:right;" for the InlineStyle. The inputText is inside of an af:Column in af:Table. If the inputtext is readonly=false, it works properly and renders right-aligned. If readonly=true, then it renders left-aligned. I have also tried setting inlineStyle for the column to text-align:right;, and I get the same behavior.
    Regards,
    John

    John,
    Try adding formatType="number" to your af:column (if you want all data in that column aligned to the right). If you don't want the entire column right aligned, try using disabled instead of readonly.
    Jim

  • Outlook 2007 cached mode not working for old exchange 2003 users

    For some reason outlook isn't receiving emails straight away when in cached mode for users which we moved (few years ago) from exchange 2003 to 2007 (we now have everyone on exchange 2010). I checked the security tab in AD and compared new and old users
    and the permissions are completely different.
    Creating a new AD account and linking the old email account to it, fixes the issue but that's not really an option for over 100 users.
    Has anyone else had this issue?

    Hello,
    What's the difference between the permissions?
    Can the users receive emails from OWA?
    In addition, please make sure your Outlook 2007 has installed the latest update. And try to use
    outlook/cleanips and check if it helps. See:
    http://support.microsoft.com/kb/968773/en-us
    Best Regards,
    Steve Fan
    TechNet Community Support

  • Anyconnect not working for Mac OS X users

    I have AnyConnect newly configured on my ASA 5550, running 8.2.x code; however, Mac users cannot connect using the Apple client, nor using the Cisco AnyConnect client - they are getting a "posture error" of some kind or the laptop is failing some kind of machine profiling.
    Help - I have no Apple OS experience on this.
    Thanks,
    Marc

    Thanks for your reply;
    Here are the relevant parts of the ASA config:
    crypto ipsec transform-set fdoe3desset esp-3des esp-md5-hmac
    crypto ipsec transform-set doe-sha esp-3des esp-sha-hmac
    crypto ipsec transform-set des-sha esp-des esp-sha-hmac
    crypto ipsec transform-set remoteset esp-des esp-md5-hmac
    crypto ipsec security-association lifetime seconds 28800
    crypto ipsec security-association lifetime kilobytes 4608000
    crypto dynamic-map fdoedynmap 65530 set transform-set remoteset
    crypto dynamic-map fdoedynmap 65530 set security-association lifetime seconds 7200
    crypto map remotemap 65535 ipsec-isakmp dynamic fdoedynmap
    crypto map remotemap interface outside
    crypto ca trustpoint ASDM_TrustPoint0
    enrollment terminal
    subject-name ------------------
    keypair doesslkey
    crl configure
    crypto ca trustpoint ASDM_TrustPoint1
    enrollment terminal
    subject-name --------------------
    crl configure
    crypto isakmp identity address
    crypto isakmp enable outside
    crypto isakmp policy 20
    authentication pre-share
    encryption des
    hash md5
    group 2
    lifetime 3600
    ** snip **
    crypto isakmp policy 70
    authentication pre-share
    encryption 3des
    hash md5
    group 1
    lifetime 28800
    crypto isakmp policy 65535
    authentication pre-share
    encryption 3des
    hash sha
    group 2
    lifetime 86400
    webvpn
    enable outside
    csd image disk0:/csd_3.6.6203-k9.pkg
    csd enable
    svc image disk0:/anyconnect-win-3.0.10055-k9.pkg 1
    svc image disk0:/anyconnect-macosx-i386-3.1.00495-k9.pkg 2
    svc image disk0:/anyconnect-linux-3.0.10055-k9.pkg 3
    svc enable
    group-policy fdoe_vpn internal
    group-policy fdoe_vpn attributes
    wins-server value xx.xx.xx.xx
    dns-server value yy.yy.yy.yy
    vpn-idle-timeout 240
    vpn-session-timeout 720
    vpn-tunnel-protocol IPSec svc
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value split
    default-domain value fldoe.int
    The user has an AnyConnect client installed on his Apple laptop; I wasn't aware that there was a component that needed to be installed in the ASA for AnyConnect clients to work. Am I confusing AnyConnect with another web SSL VPN application for the ASA 5550?

  • 11G Modplsql Basic Authentication not working for globally identified database users

    I have a modplsql dad that uses Basic authentication.  When I supply a username and password where the database user is locally defined in the database using the "identified by" syntax the authentication works perfectly and the modplsql app works.  When I try to authenticate a database user that is defined in the database using the "identified globally" syntax authentication fails.  Any idea on how to get modplsql app to work with users identified via OID?
    Thanks,
    Phil

    Hi,
    Before deploying, have you changed:
    Application properties -> Deployment
    Remove the selection from "Auto Generate and Syncronize weblogic-jdc.xml ....."
    Kind Regards

Maybe you are looking for

  • How can i change the apple ID in my 2nd hand macbook air, i have no more contact with the first owner. thanks

    how can i change the apple ID in my 2nd hand macbook air, i have no more contact with the first owner. thanks i already have an apple ID, but it seems that the original ID is locked to the first owner.

  • Any way to get around laser flashing black when moving?

    I am authoring a project that has a flash animation that I converted to an mpeg2 that starts playing right after you put the dvd in. After the 3 second animation that also includes audio it goes to my main menu. I have the end jump on the animation s

  • Can I recover only C Drive on Satellite A300 with recovery disk?

    Hello there! I'm new in the new type of slipstreaming Windows. I was familiar with the old one with Norton ghost. It was easy for me, but I have a problem with the new one. I want to recover only C drive on my laptop with a different size than the fa

  • Need to send a link in mail using apex

    Hi, I need to send a mail using apex which will contain a link for a specific page. For sending mail , I used the following query: for c1 in (select EMAIL_ADDRESS              from USER_DETAILS             where USER_NAME= :P4_USER_NAME and EMAIL_ADD

  • Select options to internal table

    i have selected some values in the range say 100 to 200 using select options....is there any way to get these values in an internal table? also does select option work with alpha numeric values eg : if i want to select between a100 and b200?