Microsoft Dynamics CMR 4.0. CrmService

narayanaraya Member Posts: 2
edited 2008-08-27 in Dynamics CRM
Hi everyone,

Actually I need to prove if I can access the web services of one CRM sever
of other domain, so actually they provide me the credentials to authenticate,
I entered to the CRM and they work. So to test it I made that test code in
one simple web site in C#:

CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; // Use Active Directory authentication.
token.OrganizationName = "<OrgName>";

CrmService service = new CrmService();

service.Url =
service.CrmAuthenticationTokenValue = token;
//service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Credentials = new System.Net.NetworkCredential("<user>",
"<password>", "<domain>");

account oAccount = new account(); = "Mike Test";

TargetCreateAccount target = new TargetCreateAccount();
target.Account = oAccount;
CreateRequest request = new CreateRequest();
request.Target = target;

CreateResponse created = (CreateResponse)service.Execute(request);

So, when it executes "(CreateResponse)service.Execute(request)" it raise an
"The request failed with HTTP status 401: Unauthorized". So waht can be the
problem, because I prove it using:

// Use the global user ID of the system user that is to be
token.CallerId = new Guid("94092D6F-B367-DC11-9C93-0003FFDFCE28");

And with the default credentials and keep raising the error. Also I find one
resource that explain something of the <impersonate> tag in web.config, but I
don't think that it should be the problem because what happen if we use
Windows Forms ?? So it's so important to me fix this problem, any help ??

Sign In or Register to comment.