2014-02-17 84 views
0

我在.net中有一個web服務,它需要NTLM(基於Windows的IIS服務器)身份驗證,然後才能進行訪問。我如何從iOS客戶端獲得NTLM認證來自ios的NTLM身份驗證客戶端

+0

我還沒有嘗試過自己,但也許這會有所幫助: http://stackoverflow.com/questions/12483465/afnetworking-ntlm-authentication –

+0

我試過這個代碼。但它不被稱爲didReceiveAuthenticationChallenge委託。 – Musthafa

回答

1

您可以創建一個NSURLConnection的並執行其委託方法

  • (無效)連接:(NSURLConnection的*)連接 willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)挑戰

在此委託,檢查挑戰

[challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM] 

如果它是來回米NTLM,然後發送憑證

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

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