Musthafa
Musthafa

Reputation: 862

NTLM authentication from ios Client

I have a web-service in .net , that requires NTLM (Windows based in IIS Server) authentication before it can be access . How would I get NTLM-authenticated from iOS Client.

Upvotes: 1

Views: 2433

Answers (1)

Roy Ma
Roy Ma

Reputation: 1933

You can create a NSURLConnection and implement its delegate method

  • (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

In this delegate, check the challenge

[challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM]

if it is from the NTLM, then send the credential

NSURLCredential *credentail = [NSURLCredential
                                   credentialWithUser:<Your username>
                                   password: <Your password>
                                   persistence:NSURLCredentialPersistenceForSession];

[[challenge sender] useCredential:credentail forAuthenticationChallenge:_challenge];

Upvotes: 2

Related Questions