针对IIS7和Windows 2008的iOS“didReceiveAuthenticationChallen
发布时间:2020-12-14 05:36:39 所属栏目:Windows 来源:网络整理
导读:我在iOS编程中遇到了一些身份验证问题.我有一个代码在 Windows 2003上完美地对抗IIS6,但在带有IIS7的Windows Server 2008上不起作用.两台服务器上的安全选项相同(无匿名访问和“集成Windows身份验证”). 这是“didReceiveAuthenticationChallenge”委托的代
我在iOS编程中遇到了一些身份验证问题.我有一个代码在
Windows 2003上完美地对抗IIS6,但在带有IIS7的Windows Server 2008上不起作用.两台服务器上的安全选项相同(无匿名访问和“集成Windows身份验证”).
这是“didReceiveAuthenticationChallenge”委托的代码: -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { //USE STORED CREDENTIALS Credentials* cred = [[Credentials alloc] init]; NSString* userName = cred.userName; NSString* pass = cred.pass; NSString* authMethod = [[challenge protectionSpace] authenticationMethod]; //Kerberos (Negotiate) needs "user@realm" as username //NTLM Needs domainusername if ([authMethod isEqualToString:NSURLAuthenticationMethodNTLM]) { userName = [NSString stringWithFormat:@"%@%@",@"es",userName]; } if ([authMethod isEqualToString:NSURLAuthenticationMethodNegotiate]) { userName = [NSString stringWithFormat:@"%@%@",userName,@"@subdomain.domain.com"]; } NSLog(@"Auth method in use: %@",authMethod); NSLog(@"User: %@",userName); NSLog(@"Pass: %@",pass); if ([challenge previousFailureCount] <= 1) { NSLog(@"received authentication challenge"); NSURLCredential *credential; credential = [NSURLCredential credentialWithUser:userName password:pass persistence:NSURLCredentialPersistenceForSession]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } else { NSLog(@"Authentication error"); NSLog(@"Failed login with status code: %d",[(NSHTTPURLResponse*)[challenge failureResponse]statusCode]); [[challenge sender] cancelAuthenticationChallenge:challenge]; } } 解决方法
最后,我发现了错误…问题与Windows 2008 IIS7服务器上的身份验证方法有关.
使用“集成Windows身份验证”时,服务器可以使用NTLM或Kerberos.我的2008服务器总是使用kerberos,即使这些机器上没有配置Kerberos. 解决方案是编辑IIS Metabase以强制NTML身份验证. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何删除文件以及Windows上的所有硬链接?
- windows – DFS-R:如何离线重新同步,删除大量数据
- “Microsoft”有一个用于解决Exchange问??题的在线工具 –
- windows-server-2008 – MSIZAP仍然有用,还是已经过时了?
- 使用Win8进行Javascript漫游设置
- castle-windsor – 在哪里可以找到Castle.MicroKernel.dll
- 使用Windows Azure存储进行备份
- batch-file – 在IF语句WinXP Batch Script中使用OR
- 微信图片解决方法-windows版的dat文件
- 使用额外的输入自定义WiX Burn主题
推荐文章
站长推荐
- windows-server-2008-r2 – 根据瘦客户端位置为远
- windows-server-2012 – RackSpace Cloud中IIS8和
- 在Windows上设置gVim
- 在Windows 2012中使用ECDHE-ECDSA-AES256-GCM-SH
- wpf调试错误输出System.WIndows.Data错误25
- Windows上的Java / MongoDB消息长度错误,但Linux
- 安装了新的Windows服务,无法启动:“系统错误2 …
- Windows上未注册的Virtualbox OS X虚拟机上的Mac
- windows-xp – 将Windows休眠文件移动到其他驱动
- Windows代码页与标准C/C++文件名的交互?
热点阅读