I have this code that works in a unit test but doesn't work when executed in the context of a plugin. What the code does is try to create a lead by calling the crm4 webservice.
When the plugin executes I get the following exception: "HTTP status 401: Unauthorized"
This is the code that initialises an instance of the webservice
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = GetConfig("crm.organisation_name");
_crmService = new CrmService(GetConfig("webservice.crm"));
_crmService.CrmAuthenticationTokenValue = token;
_crmService.UseDefaultCredentials = false;
_crmService.PreAuthenticate = false;
_crmService.Credentials = new NetworkCredential(GetConfig("crm.user_username"),
GetConfig("crm.user_password"),
GetConfig("crm.user_domain"));
Anyone have advice on what I can try next? The lead is created when the test runs, and the configuration information is the same in the unit test as it is when the app is executing the plugin.