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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

Code Execution under System Account

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

Hi,

I am trying to run a item event handler. Some of the users will not be having the permissions to execute the code, hence I am trying to run the code under the system account, regardless of the user signed in.

This is the code I have tried:

[CODE]

SPUser user = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
SPUserToken superToken = user.UserToken;
 using (SPSite site = new SPSite(SPContext.Current.Web.Url, superToken))
 {

}

[/CODE]

I would like to execute my code block to all the users. Hence I had tried to use the System Account. But when I try to execute the code, I am getting error as "Object reference not set to an instance of an object." when the code is trying to execute the below line:

[CODE]

SPUser user = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];

[/CODE]

How to execute the code using System Account, so that all users have the rights.

Thank you




View Complete Post


More Related Resource Links

Code Name WinFS: Revolutionary File Storage System Lets Users Search and Manage Files Based on Conte

  

One of the monumental problems organizations face today is aggregating information that's stored in disparate formats. Knowledge workers have long wanted to be able to search for content independent of format. The next version of the Windows operating system, code-named "Longhorn," boasts a new storage subsystem that makes that task easier. That subsystem, code-named "WinFS," allows the user to perform searches based on the metadata of the stored item, regardless of what type of file it is or which application created it. This article covers the basic architecture of WinFS and explains how to use the WinFS managed API.

Richard Grimes

MSDN Magazine January 2004


WMI and .NET: System.Management Lets You Take Advantage of WMI APIs within Managed Code

  

Visual Studio .NET and the Microsoft .NET Framework SDK provide a new set of APIs and tools that let you consume Windows Management Instrumentation (WMI) data and events from managed .NET applications. After presenting an overview of what's new for WMI in the .NET Framework and the Visual Studio .NET environment, the author provides an in-depth exploration of the Management Extensions in Visual Studio .NET for Server Explorer. These extensions help you develop management-aware software and come in handy in a variety of distributed application development scenarios.

Zina Pozen

MSDN Magazine May 2002


System.Data.SqlClient.SqlException: Login failed for user . Reason: The account is disable

  

Hi All,

Thank you for advance.

I created a widows service for mail schedule with c#.net and sql server 2005 and it is working fine for past one year.

now sometimes i am getting the "System.Data.SqlClient.SqlException: Login failed for user '<UserName>'. Reason: The account is disabled." error.

then i restarted the windows service manually and working.

what is the problem in my sql server connection and how to fix that issue?


Sharepoint site collections accessible only by system account

  
I I have setup a VM to start palying with SP development, everything running under administrator (sql, sharepoint services....). After succefully creating the root on port 80 and a couple of site collections, whenever I shoot IE http://mymoss or any othe site collection, I go right away to the web site without the usual authentification dialog box. On the right jand side, I see I am logged in as "System account". When I try to "sign in as a different user", enter domain\administrator, who is owner, the dialog box just keeps coming back and I can not log. . Thanks in advance

The Sanboxed code execution request was refused because the sandboxed code host service was too busy

  
I am getting following error when I am running my sandbx solution ona virtual machine. "The Sanboxed code execution request was refused because the sandboxed code host service was too busy to handle the request" I verified  in central admin that my  Usercode service is already running. I also tried to run below script using powershell. $acl = Get-Acl HKLM:\System\CurrentControlSet\Control\ComputerName $person = [System.Security.Principal.NTAccount]"Users" $access = [System.Security.AccessControl.RegistryRights]::FullControl $inheritance = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit" $propagation = [System.Security.AccessControl.PropagationFlags]::None $type = [System.Security.AccessControl.AccessControlType]::Allow $rule = New-Object System.Security.AccessControl.RegistryAccessRule($person, $access, $inheritance, $propagation, $type) $acl.AddAccessRule($rule) Set-Acl HKLM:\System\CurrentControlSet\Control\ComputerName $acl Any pointer would be highly appreciated!!  

change system account to username?

  
HI, I have created out-of-box workflow ,in the version history the modifiedby column  showing as system account instead of username. so want to display actual username instead of system account. help is appreciated. Thanks.

System.Data.SqlClient.SqlException was unhandled by user code

  
System.Data.SqlClient.SqlException was unhandled by user code  Message=Incorrect syntax near '01'.Unclosed quotation mark after the character string ' from month_day where month_name=datename(month,dateadd(month,01,0)-1)'.  Source=.Net SqlClient Data Provider  ErrorCode=-2146232060   LineNumber=1  Number=102  Procedure=""  Server=W2003-VM1-MK  State=1  StackTrace:       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()       at System.Data.SqlClient.SqlDataReader.get_MetaData()       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)   &nbs

How to change the System Account into Domain Administrator account in Sharepoint?

  
I'm attaching the captured image from the Central Admin of our Sharepoint Server. (http://www.experts-exchange.com/images/346242/Central-Admin.jpg) As you can see from the Central Admin image, the user account shown is "System Account", in whereas I logged in as our Domain Administrator. Then when you check it's info from My Settings, the details from the captured image System Account Info was shown. ( http://www.experts-exchange.com/images/346243/System-Account-Info.jpg) How can I change it as be DOMAIN\Administrator & not SHAREPOINT\system or System Account? Please advise...  

Changing Properties/Attributes of a Webpart in inline code block - Error 'System.Web.UI.WebControl

  
I'm trying this code below, but gettting error: System.Web.UI.WebControls.WebParts.WebPart' does not contain a definition for 'FilterValue1' I need to change the value of the FilterValue1 properties of a content Query WebPart with title = Applicant Files. Thanks in Advance!
protected override void OnLoad(EventArgs e) {  base.OnLoad(e); SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite SiteCollection = new SPSite("https://somesite/")) { SPWeb myWeb = SiteCollection.OpenWeb(); myWeb.AllowUnsafeUpdates = true; Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null; mgr = myWeb.GetLimitedWebPartManager("default.aspx",System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared); foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts) { if (myWebPart.Title == "Applicant Files") { myWebPart.FilterValue1 = "/13"; mgr.SaveChanges(myWebPart); break; } } } }); }

approval workflow showing modified name as system account

  
Hi, I have an approval workflow for page library, when normal user, who have contribute permissions has modified the page content , but the version history of the page showing the modified name as system account instead actual name. Here i need to display actual user name. thanks.

No available sandboxed code execution server could be found

  
I am deploying the web parts as the sandboxed solution to the sharepoint 2010 environment and getting following error - "No available sandboxed code execution server could be found.", any idea?

Code in an event handler not working when used with system reflection.

  
Hi, I am presently writing an application that uses an MDI form with a ToolStrip on it. I have the need to build the menu items dynamically using an XML file. The format of the XML file is as follows: <ContextMenu EventHandlerHost="vFrmPDUsetup"> <!-- These styles will be applied to the menu items. Individual menu item styles can be override by defining as an attibute to the specific menu item, see below --> <Style> <MenuStripBackColour>Transparent</MenuStripBackColour> <BackColour></BackColour> <ForeColour>Chartreuse</ForeColour> <BackImage></BackImage> <!-- Must exist in Images folder --> <FontName>Tahoma</FontName> <FontSize>10</FontSize> <FontStyle>Bold</FontStyle> </Style> <!-- Attributes: Key = Resource Key name in resource file Image = image to display before text, image must exist in Images folder BackImage = background image, image must exist in Images folder BackColour = background colour as colour name ForeColour = foreground colour as colour name FontSize = size of font as value Seperator = add a menu seperator OnClick = click event pointing to the event handler method which must be defined as the MenuItem_ + <attibute value> &

office search & Error 6482 during encryption or decryption. System error code 0

  

Occured when changed the password, all steps were successfull.

Same problem :http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/6194945b-1ec5-48b4-b827-d4ab998e046c

 Error Information:

04/05/2010 20:08:09.56 OWSTIMER.EXE (0x125C) 0x101C Office Server Office Server Shared Services 7u16 Critical Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchAdminSharedWebServiceInstance (3a49bdd9-0f3e-4044-8def-78a59dd567c1). Reason: Error during encryption or decryption. System error code 0. Techinal Support Details: System.ArgumentException: Error during encryption or decryption. System error code 0. at Microsoft.SharePoint.Administration.SPCredentialManager.DecryptWithMasterKey(Byte[] rgbEncryptedPassphrase) at Microsoft.SharePoint.Administration.SPEncryptedString.GetSecureStringValue(Byte[] rgbEncryptedAlternateKey) at Microsoft.SharePoint.Administration.SPEncryptedString.GetSecureStringValue() at Microsoft.SharePoint.Administration.SPEncryptedString.get_SecureStringValue() at Microsoft.SharePoint.Adm... 04/05/2010 20:08:09.56* OWSTIMER.EXE (0x125C) 0x101C Office Server Office Server Shared Services 7u16 Critical ...inistration.SPProcessIdentity.get_

Sharepoint Designer worflow dont start due to infopath "system account" submission

  

After lot of search i was able to submit the browser enabled infopath form to sharepoint library as anonymous user using following link

http://blog.metrostarsystems.com/2009/06/04/anonymously-submit-infopath-form-to-sharepoint-library/

but the form submit as system account, which makes the sharepoint designer workflow not working on the forms library.

so can any body help me in resolving the code to impersonate user in the infopath submit button.

public void CTRL19_5_Clicked(object sender, ClickedEventArgs e)   
        {
            string siteStr = "http://sharepointwebapplication/";
            SPSite tempSite = new SPSite(siteStr);
            SPUserToken systoken = tempSite.SystemAccount.UserToken;
            using (SPSite site = new SPSite(siteStr, systoken))
       

Sharepoint Designer worflow wontstart due to infopath "system account" submission

  

After lot of search i was able to submit the browser enabled infopath form to sharepoint library as anonymous user using following link

http://blog.metrostarsystems.com/2009/06/04/anonymously-submit-infopath-form-to-sharepoint-library/

but the form submit as system account, which makes the sharepoint designer workflow not working on the forms library.

so can any body help me in resolving the code to impersonate user in the infopath submit button.

public void CTRL19_5_Clicked(object sender, ClickedEventArgs e)   
        {
            string siteStr = "http://sharepointwebapplication/";
            SPSite tempSite = new SPSite(siteStr);
            SPUserToken systoken = tempSite.SystemAccount.UserToken;
            using (SPSite site = new SPSite(siteStr, systoken))
            {
      &

NT Authority \System Account Having SysAdmin Server Role

  

Looking to tighten security access to a SQL Server 2008 instance based on Windows 2003 Server clusters.

Is their any downside risk to revoking the sysadmin role from this account?  We've established all our services to run under domain service accounts we had set up.

Are there features or functions in SQL 2008 that depend on this account being present and having elevated priviledges?

 

thks

 


System account randomly creates documents

  
The System Account randomly creates a document called template.doc, which is an empty word document.  This happens when a document is uploaded or modified, but not all the time.  We are monitoring and removing these templates whenever we find them, but this is not a solution. Please advise!
Categories: 
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