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.