You can use the following method to get client context for your environment.
CODE
CRM On Premise Usage
IOrganizationService service = GetClientContext("https://test.crm12.com/orgname", "username", "password", "domain");
CRM Online Usage
IOrganizationService service = GetClientContext("https://test.crm12.dynamics.com", "username", "password", string.Empty);