Microsoft Dynamics CMR 4.0. CrmService

naraya
Member Posts: 2
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 =
"https://<server>:<port>/MSCRMServices/2007/CrmService.asmx";
service.CrmAuthenticationTokenValue = token;
//service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Credentials = new System.Net.NetworkCredential("<user>",
"<password>", "<domain>");
account oAccount = new account();
oAccount.name = "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
error
"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
impersonated.
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 ??
Thanks,
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 =
"https://<server>:<port>/MSCRMServices/2007/CrmService.asmx";
service.CrmAuthenticationTokenValue = token;
//service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Credentials = new System.Net.NetworkCredential("<user>",
"<password>", "<domain>");
account oAccount = new account();
oAccount.name = "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
error
"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
impersonated.
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 ??
Thanks,
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions