NTLM authentication from ios Client

走远了吗. 提交于 2019-12-08 11:50:25

问题


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.


回答1:


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];


来源:https://stackoverflow.com/questions/21825164/ntlm-authentication-from-ios-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!