views:

153

answers:

0

Hi, I am trying since for a longer time to post parameters to Outlook Web Access 2007 (owaauth.dll) for signing on. But it refuses.

This is the way I am doing (which is already working within a delphi program):

NSString *strUsername = [[NSUserDefaults standardUserDefaults] stringForKey:@"mailUserName"];
NSString *strPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"mailPassword"];
NSString *postString = [NSString stringWithFormat:@"destination=https%3A%2F%2Fowa.MYHOST.com%2Fexchange&flags=0&username=%@&password=%@", strUsername, strPassword];
NSData *myRequestData = [NSData dataWithBytes:[postString UTF8String] length:[postString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString: @"https://owa.MYHOST.com/exchange/owaauth.dll"]]; 
[request setHTTPMethod:@"POST"];
[request setHTTPBody:myRequestData];
NSDictionary *headerFieldsDict = [NSDictionary
      dictionaryWithObjectsAndKeys:
   @"application/x-www-form-urlencoded",@"Content-type",
   @"https://owa.MYHOST.com/exchweb/bin/auth/owalogon.asp?url=https://owa.MYHOST.com/exchange&reason=0&replaceCurrent=1",@"Referer", nil];
[request setAllHTTPHeaderFields:headerFieldsDict]; 
[webView loadRequest:request];

It seems that UIWebView does not allow to change the user-agent in its header during a post request.

Does anyone have an idea how to solve this? Here is a .NET tutorial for the same thing (a bit more complex, I am suppressed as my solution was working within my delphi program): http://blog.mbcharbonneau.com/2006/10/26/using-net-and-webdav-to-access-an-exchange-server/

Anyway, many thanks!!!