0

我正在尝试在 InfoPath 表单的代码隐藏中使用标准 SharePoint Web 服务 GetWeb。该表单作为工作流的一部分托管,因此使用 Forms Services 加载到浏览器中。因此,它在登录到 SharePoint 的当前用户的凭据上运行。如果用户在站点的 Owner 组中,则 Web 服务运行,但如果用户在 Contributor 或 Reader 组中,则会给出“HTTP 401 Unauthorized”错误。在此之后我还使用了 GetLists Web 服务,但只要用户具有 Reader 权限,它就会运行。

我只使用 GetWeb 调用来获取 GetList 调用所需的 WebId 作为参数。我通过将 WebId 传递到表单而不是让表单查找它来解决我的权限问题。所以现在一切都好。

但是,我想知道为什么 GetWeb 需要更高的权限以及如何/是否可以控制这些权限。我没有找到任何关于不同开箱即用 Web 服务所需权限的文档,更不用说您如何更改它们了。

[注意] 我没有使用数据连接文件是有原因的,但还是感谢您提出建议。

4

2 回答 2

2

You can eliminate the need to hard coding web service credentials by managing the web service details in Data Connection libraries. The UDCX file includes the schema to store web service credentials and the file itself can be centrally managed from Central Admin.

Using data connection files in central admin: http://aidangarnish.net/blog/post/2008/11/Using-centrally-managed-SharePoint-data-connection-files-with-InfoPath-2007.aspx

Web service credentoils at (7): http://sheetal-d.spaces.live.com/Blog/cns!237C3DEA7120098B!658.entry

于 2009-03-24T18:10:38.293 回答
0

如果您将 sharepoint 客户端用于 GetList。然后你可以看看下面的代码。

ClientContext context = new ClientContext(siteURL);
UserInfo user = new UserInfo();
SecureString passWord = new SecureString();
foreach (char c in user.Pwd.ToCharArray()) passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials(user.UserName, passWord);
//context.Credentials = new System.Net.NetworkCredential(userName, password);
Web web = context.Web;
List list = web.Lists.GetByTitle(documentLibraryName);

CamlQuery query = new CamlQuery();
ListItemCollection items = list.GetItems(query);
context.Load(items);
context.ExecuteQuery();
于 2015-09-21T07:19:01.953 回答