use*_*506 8 iphone sharepoint claims-based-identity sharepoint-2010 ios
我为iPhone制作了一个简单的SharePoint客户端应用程序,它需要访问一些SharePoint Web服务(主要是/_vti_bin/Lists.asmx).我在查找如何在较新的SharePoint环境(如Office365)上执行此操作时遇到了麻烦.
对于具有基于表单的身份验证的旧BPOS环境,我能够通过简单的实现didReceiveAuthenticationChallenge方法对这些服务进行身份验证;
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
NSURLCredential *newCredential = [NSURLCredential credentialWithUser:username
password:password
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:newCredential
forAuthenticationChallenge:challenge];
}
Run Code Online (Sandbox Code Playgroud)
这显然不再适用于具有声明身份验证的SharePoint网站,因此我做了一些研究,发现我需要将FedAuthcookie附加到请求中.
http://msdn.microsoft.com/en-us/library/hh147177.aspx
根据这篇文章,使用.NET Apps,似乎可以FedAuth使用WININET.dll 检索那些HTTPOnly cookie,但我想这在iPhone上不可用?
然后,我看到SharePlus应用呈现UIWebView,并让用户首先登录到他们的Office365帐户浏览器屏幕上(这是相同的概念为"启用用户登录远程认证"上述文章的部分解释).
所以,我试图FedAuth通过登录Office365帐户UIWebView,以某种方式访问这些cookie ,但是[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]我没有让我访问HTTPOnly cookie.
有没有办法在iPhone应用程序上实现声明身份验证,而无需指定中间.NET服务来处理身份验证,或者要求用户关闭这些cookie上的HTTPOnly属性?
对不起,我是SharePoint新手,所以我甚至可能没有找到正确的方向,但我很感激任何有关获取iPhone应用程序的声明身份验证的建议.提前致谢!
我自己已经弄清楚了这一点。不得不嘲笑自己的愚蠢和急躁。
首先,[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]请允许您访问 HTTPOnly cookie。不过,当用户在 上登录 Office 365 时UIWebView,(void)webViewDidFinishLoad:(UIWebView *)webView委托方法会被调用多次,因此您只需等待 FedAuth 出现在 cookie jar 中即可。
这是我的(void)webViewDidFinishLoad:(UIWebView *)webView实现;
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cookiesArray = [storage cookies];
for (NSHTTPCookie *cookie in cookiesArray) {
if ([[cookie name] isEqualToString:@"FedAuth"]) {
/*** DO WHATEVER YOU WANT WITH THE COOKIE ***/
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
获得 cookie 后,您只需在调用 SharePoint Web 服务时将其附加到NSURLRequestusing方法即可。(void)setAllHTTPHeaderFields:(NSDictionary *)headerFields
希望这对某人有帮助。
| 归档时间: |
|
| 查看次数: |
3579 次 |
| 最近记录: |