4
votes

I would like to create an iPad app for MS Dynamics CRM 2011. We have a CRM system which you can log in anywhere in the world with AD username and password.

I know CRM comes with Discovery service, Organization Service and OData Service. But I don't know how I would use those services? I'd like to know how I should authenticate the user?

Here is a sample code that I have found but doesn't work.:(

NSString *username = @"domain/username";
NSString *password = @"password";
NSString *loginURL = @"http://server/OrgName/XRMServices/2011/OrganizationData.svc/";

NSURL *url = [NSURL URLWithString:loginURL];

NSString *JSONString = [NSString stringWithFormat:@"{\"user id\":\"%@\",\"password\":\"%@\"}", username, password];

NSData *JSONBody = [JSONString dataUsingEncoding:NSUTF8StringEncoding];

NSMutableURLRequest *loginRequest = [[NSMutableURLRequest alloc] initWithURL:url];
loginRequest.HTTPMethod = @"POST";
loginRequest.HTTPBody = JSONBody;

NSOperationQueue *queue = [NSOperationQueue new];

[NSURLConnection sendAsynchronousRequest:loginRequest
                 queue:queue
                 completionHandler:^(NSURLResponse *response, NSData *data, 
                                     NSError *error){

                                   // Manage the response here.
                                    [self fetchedData:data];
                                   NSLog(@"error:%@", error);
                                   NSLog(@"response:%@", response);}];
    }

Thanks for your help.

2

2 Answers

0
votes

Most implementations and products I have seen use a mediation server or service to proxy calls into CRM. The REST service available is OK for general CRUD operations, but does lack features that the other SDKs provide.

Advantages:

  • Implement a SDK that better favors the clients you want to support
  • You get the full complement of features available in any of the CRM SDKs

Disadvantages:

  • It can be a lot of work.

If its essential to connect directly from client to CRM installation. Consider accessing the OData source via a browser while capturing the traffic with either a local proxy or the browser's DEV tools. Write code that creates those same web requests. Theoretically, this is as safe as using a browser to access CRM. Use appropriate means to encrypt, mask, and obscure your traffic.

There are other alternatives that I have not experienced personally. I can offer them for research but can't speak confidently about them.

MSDN: CRM 2011 REST Service Documentation

MSDN: CRM 2011 SDK Overview

0
votes

If you try to authenticate against Dynamics CRM from iOS natively you will need A LOT of time.... and when I say a lot is, A LOT.

There are different CRM configurations On-Premise / On-line, and it will be even more tricky with IFD and https (where you actually need to authenticate against ADFS, validate the certificate chain... etc).

The easiest thing you could begin with is to expose a Proxy Web service, implemented in .NET , that deals with the authentication against CRM for you, and then authenticate that web service from your iOS app (using a normal https request and a more easy authentication mechanism)

But, even doing that, it's still a lot of time.