I am trying to execute the following code:
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,