|Error – 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.|
|Scenario: In C# invoked the SPWebApplication.Lookup() method.|
|Solution 1: Add the current user to the SQL Server > Security folder.
Solution 2: Run the application in the context of Privileged user who has above access.
Use Command Prompt to execute the command:
runas /user:DOMAINUSERNAME “YourApplicationPath”