.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How does RunWithElevatedPrivilages work out of SharePoint context?

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :SharePoint


I have next code:

SPSecurity.RunWithElevatedPrivileges(() => {
   SPWebApplicationCollection webApplicationCollection = SPWebService.ContentService.WebApplications;
   foreach (SPWebApplication webApplication in webApplicationCollection)
      foreach (SPSite site in webApplication.Sites)
         using (SPWeb rootWeb = site.RootWeb)
            Console.WriteLine(rootWeb.Title + "\t" + rootWeb.Url);                        

In case I run it in Console Application it works fine.

In case I put it into xml web service w

View Complete Post

More Related Resource Links

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

Quick Note: Using SharePoint Designer 2010 to Work with Web Parts

Learn to create an XSLT List View Web Part within SharePoint Designer 2010 that displays a list of employees on the Home page of local web site.

Sharepoint: In Calculated Column, Code with multiple "IF" condition does not work.

Implemantation:  Calculate expected resolve date exclude "Saturday" and "Sunday"  based on Priority and Severity.Columns are:1. Priority:2. Severity:3. Raised on: Date record createdCode: Below is the code which contains multiple "If" conditions. For quick undersatnding, i separated major If condition. Below code does not work and sharepoint gives me Sytax error message. =IF(OR(Priority="Critical",Severity="Critical"),IF(TEXT(WEEKDAY([Raised on]+1),"dddd")="Saturday",[Raised on]+3,[Raised on]+1),     IF(OR(Priority="HIGH",Severity="HIGH"), IF(TEXT(WEEKDAY([Raised on]+1),"dddd")="Saturday",[Raised on]+4, IF(TEXT(WEEKDAY([Raised on]+2),"dddd")="Saturday",[Raised on]+4,[Raised on]+2)) ,   IF(OR(Priority="MEDIUM",Severity="MEDIUM"), IF(TEXT(WEEKDAY([Raised on]+1),"dddd")="Saturday",[Raised on]+5, IF(TEXT(WEEKDAY([Raised on]+2),"dddd")="Saturday",[Raised on]+5, IF(TEXT(WEEKDAY([Raised on]+3),"dddd")="Saturday",[Raised on]+5,[Raised on]+3)) ) ,   IF(OR(Priority="LOW",Severity="LOW"), IF(TEXT(WEEKDAY([Raised on]+1),"dddd")="Saturday",[Raised on]+6, IF(TEXT(WEEKDAY([Raised on]+2),"dddd")="Saturday",[Raised on]+6, IF(TEXT

How does work Outlook overlay in SharePoint 2010?

I want to add Calendar of Exchange in Sharepoint 2010. Does Sharepoint 2010 work with Exchange 2003? Thanks.

How well does SharePoint REALLY work and play with an RODC-based AD environment?

We are running into a host of interesting little problems getting SharePoint Foundation 2010 to work and play well in a DMZ where its only access to Active Directory is through a read-only domain controller (RODC).  Our SharePoint server is on the DMZ, along with an RODC, while our database server is on our internal network, along with our main AD domain controllers. The SharePoint Configuration Wizard simply WOULD NOT complete successfully until we set up a temporary firewall rule that granted the SharePoint full access to AD.  At that point, we could successfully run the SharePoint and SharePoint Farm configuration wizards, and create a site collection, identifying two domain users as site collection admins.  After we turned off the firewall rule, once again restricting the server to AD access via the RODC, we could create and access SharePoint sites just fine, so long as the users involved were the two identified as site collection administrators. However, when I tried to create a new SharePoint site group and identify a third domain user as the group owner, or add a new user to one of the existing SP site groups, or even just grant site-level permissions directly to a domain user (other than the two site collection admins), the user name would not resolve.  I suspect that the site admins resolve okay because SharePoint already has them cached in it

Can´t get the time intelligence filter to work in PerformancePoint Services/Sharepoint

Hi all, I have created a scorecard in Dashboard Designer based on an SSAS cube which looks ok in both DD and Sharepoint. As I want to connect a time filter to this I have created a TI filter in DD. In Sharepoint I have connected the filter to the scorecard with "send performancepoint values to". In "configure connection" I set source value to "PerformancePoint Values: Formula" and Connect to to "Endpoint_TIFormula". I only need to filter on year and have set the TI properties on the cube. Selected time dimension is "Year", Hierarchy level is set to Year, Member is 2008, reference date is 1/1/2008 and I have associated member level Year to Time aggregation Year. The filter is set up like this in DD: it uses the same data source as the scorecard and I use a list view. I do get the filter to work if I specify one formula for each year (e.g. Formula: "Year" and "Display Name: "2010", "Year-1" and "2009" making up two rows) but that can´t be the right way to do it, right? What i would like is a multiselect tree view where I can choose the year I want and have them display on columns. I have tried the formula Year:Year-2 and in the preview I see [Date].[Year].&[2008],[Date].[Year].&[2009],[Date].[Year].&[2008]. However, in Sharepoint the filter only show on

SharePoint 2010 Chart Web Part does not appear to work

Using the sharepoint chart web part does not appear to work. Plotting a pie chart from a list with 10 items in it.  Using a numeric field for a Y axis and a choice field for X axis. The choice field has 4 possible selections. Clearly I want a pue chart with 4 slices. What I get is a pie chart with 10 slices, not much use. Fine I thought we've got this optional 'Group by field' so I'll group by my choice field. But then I get a pie chart with one slice?! Am I being dumb or does the chart web part not work properly?

Links dont work in sharepoint central administration!!

I just installed microsoft sharepoint 3.0,I want to restore a backup of the site which is located in another server.but the links of the restore page in the central administration dont work,I typed the path to the folder containing the backup and press ok,nothing is done.

SSRS 2008R2 - go back to parent report does not work sharepoint integrated mode

I'm currently using SharePoint Foundation 2010 with SQL Server 2008R2 with the SharePoint RS add-in. I have a report with a drilldown to another report.  I can drill down correctly to the other report.  But when I do the "go back to parent report" it will take me back to the parent report, but when I try to drilldown again to another report, I get the following error. "Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near ' <!DOCTYPE html PUB'. Line: 5 Char: 62099" When I run this report in VS 2008 or Report Builder 3, I have no problems drilling down and back and forth. I only have an issue when I deploy the report to SharePoint.  I have also accessed the RDL directly outside of a webpart page, but still get the same error. Wondering if anyone else is experiencing this issue?

Access Denied while using Sharepoint designer 2007 to create a work flow

I am using Sharepoint Designer 2007 to create a work flow that sends emails to different people in a group depending on status of a record. For example, when some one reports a problem, an email is posted to concerned person and as soon as he/she checks the problem and updates the status an email is sent to next department and so on. Starting the work flow creation wizard is no problem but as soon as I press 'Finish' to create workflow I get 'Access Denied' message box. Any Ideas? I am using WSS 3.0 on 2003 Server.

XML Viewer web part and SharePoint list RSS feed doesn't work

Hello, When I want to use the XML Viewer web part and set the XML URL to an RSS feed from a SharePoint list I get this error: Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator. The URL I'm trying looks like this: http://sp2010/_layouts/listfeed.aspx?List=%7B76FD9EEE%2D9354%2D444E%2DBE3C%2DA9AE2C4B2063%7D I've seen blogpost that discuss this and they say that this is because of a security issue and that I have to enable anonymous access in order to display the RSS feed. Is this the only option there is ? I don't want to enable anonymous access on my SharePoint site. Why can't SharePoint just request the RSS feed with the credentials of the logged in user ? Or am I missing something here?

Deploying TFS2010 work item custom controls in Sharepoint portal

HI I have created work item custom controls for Web Access. I have placed the Dlls in Team Foundation Server 2010 -> Application Tier -> WebAccess -> Web -> WorkItemTracking -> Custom Controls. now, i am able to view the custom controls if i access through Team Web Access 2010. But i am unable to view the custom control when i acces through sharepoint 2007 portal. I have copied the dll and wicc file to following location C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\Tswa\CustomControls but i got the following error system.IO.FileLoadException: Could not load file or assembly. Please share me if the deployment procedure of custom controls in Sharepoint are different. Regards, Sekhar

SharePoint workflow Enable WorkflowModification doesnt work

Hi   I'm trying to enable WorkflowModification in a sequential workflow in VS Studio 2008 according to the *** of examples of microsoft but When I run my workflow I get this error: 09/14/2010 10:24:35.78  w3wp.exe (0x11FC)                        0x13A8 Windows SharePoint Services    Workflow Infrastructure        88xr Unexpected WinWF Internal Error, terminating workflow Id# 74f4bd77-7aaa-407e-90ac-f56a6184bc21  09/14/2010 10:24:35.78  w3wp.exe (0x11FC)                        0x13A8 Windows SharePoint Services    Workflow Infrastructure        98d4 Unexpected System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.SharePoint.SPException: Error in the application.     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.EnableWorkflowModification(Guid modificationId, String contextData)     --- End of inner exception stack trace ---     at System.RuntimeMethodHandle._InvokeMe

Conditional formatting on a joined subview using SharePoint Designer 2007 does not work

I have 2 SharePoint lists, one is a parent task list and the other a child task lists.  In SharePoint Designer 2007 I have created a combined datasource from these 2 lists.  From there I created a new ASPX page inserting the parent list as a dataview and the child as a subview.  So far so good, all is functioning as you would expect.    Now I need to apply conditional formatting to cells and rows in both the parent and child lists.  I can create a very simple condition on a row or cell of the parent list such as "If ID Equals '2988' format the background color as green" but no conditional formatting appears for the row where ID = 2988.  Incidentally, if I change the condition to "not equals 2988" the background changes to green. The line in the code view of Designer appears as follows:  <xsl:if test="../../../Rows/Row/@ID = '2988'">background-color: #00FF00;</xsl:if> I've seen this question asked here and in blogs but never answered.  If anyone has a solution, I would love to know what it is. Thanks; Dave  UPDATE:  it doesn't seem to matter if you add the additional fields as a joined subview or not.  If I add 2 data views, both using the linked data source which is configured to JOIN the contents of the data sources the conditional formatt

Edit in Datasheet view does not work on one SharePoint 2007 farm, works on another.

The ability to edit in datasheet view on one of our environments no longer works.  I've tried different client machines on different builds and regardless of the install every library, list, etc. when attempting to edit in datasheet view shows as read only.  Our other environments those systems work as intended with those same clients. I've searched all over and haven't found anything that helped.  Any ideas?

Unable to update Work E-Mail in My Setting of Sharepoint 2010

Hey,   i am trying to update Work E-mail in My settings but it will not allow me to edit.   when i click on Edit Items then Attach file comes as user personal information   Please suggest me solution.   Regards, Sachin Phapale  

Sharepoint 2010 search cannot work at all

HI I have just installed Sharepoint 2010 trial version. I installed with a 2 server setup - sharepoint and SQL was on separate Virtual machines. Previously the search could work. Crawl logs showed all success. Until yesterday I began to fiddle around with PDF iFilter and configuring it to make sure PDF could be searched. I consulted the following websites(http://sptwentyten.wordpress.com/2009/12/30/install-foxit-pdf-ifilter-on-sharepoint-2010-beta/ http://support.microsoft.com/kb/2293357 http://www.codeproject.com/KB/sharepoint/PDFiFIlterSharePoint2010.aspx) but faced problem along the way such as - issuing IISreset command (In the end I had to use services to stop/start IIS Admin Service), -restarting Sharepoint Search Server 14 (net stop osearch14, net start osearch14). (In the end only the local administrator account could perform this) - I also had other problems/typo so everytime I tried, I did a full crawl. Then I noticed my search could not WORK AT ALL after fiddling with Sharepoint along the way. It showed all failures in the crawl log. With 103 errors related to 'The object was not found'. It will show my top level sites even, ie http://domainname - but actually when i clicked on it, I could access. IN the event viewer, it showed Event ID 14 error. Task Category 'Gatherer', Event ID 14, Source is from 'Sharepoint Search Server'. details
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend