获取SharePoint可供用户使用的站点列表

时间:2012-04-19 11:31:26

标签: sharepoint soap

我一直在尝试使用sharepoint Web服务(来自webs.asmx)GetWebCollection来获取用户可用站点的列表。我已经使用sharepoint成功进行了身份验证,如果我在站点路径中硬编码,我可以恢复文件。但是,当我尝试使用GetWebCollection时,我收到了“403 Forbidden”错误?

以不同的方式需要什么?

或者,有没有办法告诉用户自动分配到哪个网站?

我通过SOAP(使用ASIHTTPRequest)在Objective-C中进行连接。

- (void)getUrl {

NSURL *url = [NSURL URLWithString:@"https://[server]/_vti_bin/Webs.asmx"];

requestGetSites = [ASIHTTPRequest requestWithURL:url];
[requestGetSites setDelegate:self];

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

[requestGetSites setUseCookiePersistence:NO];
[requestGetSites setUsername:@"username"];
[requestGetSites setPassword:@"password"];
[requestGetSites appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[requestGetSites addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[requestGetSites addRequestHeader:@"Host" value:@"[a server]"];
[requestGetSites addRequestHeader:@"SOAPAction" value:@"http://schemas.microsoft.com/sharepoint/soap/GetWebCollection"];

NSLog(@"Request headers are: %@", [[requestGetSites requestHeaders] description]);

[requestGetSites startSynchronous];

}

1 个答案:

答案 0 :(得分:0)

我开源了一个SharePoint库,用于连接到http://github.com/woodnathan/SPConnector

的SharePoint