Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to execute the following code:

C#
SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            HttpContext.Current.Items["FormDigestValidated"] = true;
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri(string.Format("http://{0}", swebapplicationurl)));
            SPSiteCollection sites = webApp.Sites;
            Site.Dispose();
        });


It ends up with error as follows:

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.


I am stuck. Please help.

Thanks,


[OP Answer moved to here]
Thanks for the answer.

In fact, I have an ASP.NET Web application. Which use to Access the MOSS Web Application and create Sub-sites.

This ASP.NET application works well with MOSS 2007. On the other hand, when i use to run the ASP.NET applicaiton on a server on which MOSS 2010 has been configured. The application show me the above mentioned Error.

I am trying to over come this error but till now i am failed.

Thanks,
Posted
Updated 14-Feb-12 8:26am
v5
Comments
[no name] 13-Feb-12 14:09pm    
Changed tag. This is not a MOSS 2007 question.

BTW, there is no such thing as MOSS 2010. It helps to use the correct terminology.
Sergey Alexandrovich Kryukov 8-Mar-13 15:16pm    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

FormDigest is not something you manipulate directly. The FormsDigest control is placed on all pages and used to authenticate the request. WHat is it you are trying to do? Why are you disposing of the Site in this block? Where did it come from? If it is external to this block then you should not be disposing of it here, you are running the code in a separate context.
 
Share this answer
 
Since you have provided additional information to clarify what you are attempting to accomplish.

Yes, you are getting the error because you are attempting to make changes to the configuration database with an account that doesn't have access.

Create a timer job that will accept or retrieve the information necessary. When this timer job runs it will be executed under the farm admin account that does have access to the configuration database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900