使用Web服务向共享点列表添加权限级别

时间:2009-08-03 20:44:01

标签: web-services sharepoint permissions list

我需要将权限级别添加到以下列表中:完全控制,贡献,管理层次结构,仅查看等。 我在这里看到:“programatically add user permission to a list in sharepoint”,这可以使用对象模型完成。我如何使用Web服务执行相同的操作?

我尝试使用permissions.asmx Web服务,它适用于其中一些提供正确的掩码,如1011028991 for Approve,138612833 for read,但它不适用于其他如管理层次结构,受限读取和任何其他用户创建的角色(许可级别)。而不是我得到的正确名称:自动生成的权限级别edda2384-2672-4e24-8f31-071d61a8c303

任何帮助将不胜感激。


好的,这是一个代码示例,用于获取基于此forum的代码的掩码。

string sPermissionName = "Manage Hierarchy"; // if I use Read, Approve, Contribute, Full Control, it works!
string sListName = "testList";
string sGroupName = string.Format("{0}_ManageHierarchy", sListName);

// Create an aux group just to obtain the mask number later
using (SPUserGroup.UserGroup ug = new SPUserGroup.UserGroup())
{
    ug.Credentials = new NetworkCredential("user", "pasword");
    ug.Url = "http://testSite/_vti_bin/UserGroup.asmx";
    ug.AddGroup(sGroupName, "testDomain\\user", "user", "testDomain\\user", "Manage Hierarchy test");
    ug.AddGroupToRole(sPermissionName, sGroupName);
}

using (SPPermissions.Permissions per = new SPPermissions.Permissions())
{
    per.Credentials = new NetworkCredential("user", "password");
    per.Url = "http://testSite/_vti_bin/Permissions.asmx";

    XmlNode perms = per.GetPermissionCollection(sListName, "list");
    XmlNode n = perms.SelectSingleNode(string.Format("/*[local-name()='Permissions']/*[local-name()='Permission' " +
        "and @MemberIsUser='False' and @GroupName='{0}']", sGroupName));

    // Here we get the Mask for the role
    int iMask = int.Parse(n.Attributes["Mask"].Value);
    Console.WriteLine("The mask is:{0}", iMask); // Just to see the mask, I get 2129075183 for Manage Hierarchy

    // Here I want to add some user to the list with the specified permission level
    // But I get for example: Auto-generated Permission Level edda2384-2672-4e24-8f31-071d61a8c303 
    // Also, If later I execute the GetPermissionCollection, I see that the mask they got is: 2129075199  and not what I passed which was: 2129075183 
    per.AddPermission(sListName, "list", "testDomain\\user01", "user", iMask);
    per.AddPermission(sListName, "list", "testDomain\\user02", "user", iMask);
}

0 个答案:

没有答案