iOS Sharepoint App 登录错误

标签 ios sharepoint request asihttprequest

我正在开发一个 iOS iPad 应用程序以连接到 Sharepoint。我用 ASIHTTPRequest 框架来做这件事。我的代码如下所示:

NSURL *url = [NSURL URLWithString:@"https://SHAREPOINTURL"];

NSString *soapMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<GetListCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n";

asiRequest = [ASIHTTPRequest requestWithURL:url];

[asiRequest setUsername:@"USERNAME"];
[asiRequest setPassword:@"PASSWORD"];

[asiRequest setDelegate:self];
[asiRequest appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[asiRequest addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[asiRequest startAsynchronous];

到目前为止一切顺利,但是当我调试它时,我收到 403 FORBIDDEN 错误。为什么? 在我看来,我不认为错误是用户名和密码。也许请求有问题?

最佳答案

因为你没有发布你的 url,我不得不问,你是否正在发布到 _vti_bin/authentication.asmx

如果您已经是,我只能建议这样做,因为我不知道 ASI 是否正确输入了登录信息。尝试像这样手动将其放入您的 SOAP 消息中:(来自 here)

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <Login xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <username>USERNAME</username>
      <password>PASSWORD</password>
    </Login>
  </soap:Body>
</soap:Envelope>

这应该会返回您使用其余网络服务所需的登录 cookie。

编辑:还有一件事,您需要将 SP 服务器设置为使用表单例份验证而不是 NTLM 身份验证(这是默认设置)。

关于iOS Sharepoint App 登录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13939879/

相关文章:

ios - 如何动画逆时针旋转

ios - 使用 Tableview 告诉 ios 中的用户最近对服务器的调用没有获取任何数据

sharepoint - 部署新的 Web 部件

PowerShell 映射持久共享点路径

javascript - 如何从 API 中提取数据以供 Opera Mini 使用?

php - jquery ajax请求多个返回值?

ios - AKClipPlayer 在剪辑中间播放

ios - 滚动后自定义 TableView 单元格中的标签消失

sharepoint - 在企业环境中将 global.asax 部署到 sharepoint 2010 以启用统一 DI 容器

ios - 如何在加载响应后加载 View Controller (或调用 segue)(使用 Alamofire)?