我想为 MS Dynamics CRM 2011 创建一个 iPad 应用程序。我们有一个 CRM 系统,您可以使用 AD 用户名和密码在世界任何地方登录。
我知道 CRM 带有发现服务、组织服务和 OData 服务。但我不知道我将如何使用这些服务?我想知道我应该如何验证用户?
这是我找到但不起作用的示例代码。:(
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);}];
}
谢谢你的帮助。