I'm trying to access some web services in an iPhone application.
If I GET
to the .asmx page, I authenticate and get the WSDL as expected.
However, if I POST
to the .asmx page, setting the SOAPAction, Content-Type, Content-Length, and HTTPBody, I just keep getting didReceiveAuthenticationChallenge
messages.
Additionally, I'm trying to POST to IIS using Integrated Windows Authentication (IWA), which means I'm trying to negotiate an NTLM challenge.
Click down to “Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options. Find the policy “Network Security: LAN Manager authentication level”. Right click on this policy and choose “Properties”. Choose “Send NTLMv2 response only/refuse LM & NTLM”.
The most common app authentication method is the traditional password request. Without entering the correct password, access to an app may not be granted.
NTLM authentication is still supported and must be used for Windows authentication with systems configured as a member of a workgroup. NTLM authentication is also used for local logon authentication on non-domain controllers.
A challenge from a server requiring authentication from the client.
I unfortunately found my answer. NSURLConnection cannot do NTLM authentication. Here's a post about how to do NTLM authentication using the CFNetwork stack.
HTTP Post via the CFNetwork stack
Found something even better than doing all of that tediousness: Someone who has already done it!
ASIHTTPRequest
Update: There is a workaround for iOS 4 that allows for NTLM authentication again
Sounds to me like your web-service has different read (get) and write (post) permissions. I dont think this is an issue with the iPhone or NSURLConnection at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With