سؤال

i am attempting to connect to the sharepoint server/_vti_bin/SilverlightProfileService.json/GetUserSLProfileData service to get details about users in the organization.

I am sending my request from objective-c using the ASIHTTPRequest package and am recieving "ERROR Domain=ASIHTTPRequestErrorDomain Code=3 'Authentication Needed'"

My request code:

NSURL *url = [NSURL URLWithString:@"http://aDOMAIN/_vti_bin/SilverlightProfileService.json/GetUserSLProfileData"];
NSString *jsonString = @"{\"AccountNames\": [\"intdev\\aUSER\" ]}";

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[jsonString  dataUsingEncoding:NSUTF8StringEncoding]];
[request setRequestMethod:@"POST"];

[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request addRequestHeader:@"Expect" value:@"100-continue"];

[request setUsername:@"intdev\\aUSER"];
[request setPassword:@"P@ssw0rd1"];
[request setDomain:@"aDOMAIN"];

[request startSynchronous];
NSError *error = [request error];
if (!error) {
    NSString *response = [request responseString];
    NSLog(@"%@", response);
}
else{
    NSLog(@"%@", error);
}

I have used fiddler to check the requests it IS authenticating with NTLM and i am using the correct username/password/domain.

MY REQUEST

POST http://aDOMAIN/_vti_bin/SilverlightProfileService.json/GetUserSLProfileData HTTP/1.1
Host: aDOMAIN
Expect: 100-continue
Connection: keep-alive
Accept-Encoding: gzip
Content-Type: application/json
Content-Length: 36
Connection: keep-alive
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAD0APQAWAAAAEAAQABMAQAAGgAaAIwBAAAmACYApgEAAAAAAAAAAAAABYIIAKndYKPN+sArlPt5qycejx+a89LCSC7UwM5wWr0Ld5T6ndjpxyZVBIcBAQAAAAAAABA+zhcnWc8BmvPSwkgu1MAAAAAAAgAMAEkATgBUAEQARQBWAAEAFABTAFAAMgAwADEAMwBQAE8AQwAxAAQAKABpAG4AdABkAGUAdgAuAEQAZQBwAHQARABlAHYALgBsAG8AYwBhAGwAAwA+AFMAUAAyADAAMQAzAFAATwBDADEALgBpAG4AdABkAGUAdgAuAEQAZQBwAHQARABlAHYALgBsAG8AYwBhAGwABQAaAEQAZQBwAHQARABlAHYALgBsAG8AYwBhAGwABwAIAFgVOakmWc8BAAAAAAAAAABTAFAAUABPAEMATQBZAFMASQBUAEUALgBJAE4AVABEAEUAVgAuAEQARQBQAFQARABFAFYALgBMAE8AQwBBAEwAaQBuAHQAZABlAHYAXABwADAAOAA4ADUAOQBMAGEAYwBoAGwAYQBuAHMALQBpAE0AYQBjAC4AbABvAGMAYQBsAA==
User-Agent: sharepoint 1.0 (iPhone Simulator; iPhone OS 7.1; en_US)

{"AccountNames": ["intdev\aUSER" ]}


MY RESPONSE

HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Length: 0
SPRequestGuid: 2fad879c-7cc6-700e-0000-0223ed9d2abe
request-id: 2fad879c-7cc6-700e-0000-0223ed9d2abe
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 3
SPIisLatency: 2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
WWW-Authenticate: NTLM
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
MicrosoftSharePointTeamServices: 15.0.0.4420
Date: Wed, 16 Apr 2014 03:48:09 GMT
Proxy-Support: Session-Based-Authentication

I am quite stumped and i feel as if i have tried just about everything. Any assistance whatsoever would be much appreciated.

Thanks in advance, Lachlan.

هل كانت مفيدة؟

المحلول

After much investigation I refactored my services to use AFNetworking. It was able to automatically handle all of the authentication.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top