C# sharepoint client object model 获取Web和List的权限

Web webSource = contextSource.Web;
contextSource.Load(webSource);
contextSource.ExecuteQuery();

List listSource = ClientOperateInfo.GetListMessage(contextSource, "", ListTitle);
contextSource.Load(listSource);
contextSource.ExecuteQuery();

IEnumerable webroles = contextSource.LoadQuery(webSource.RoleAssignments.Include(roleAsg => roleAsg.Member, roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name, roleDef => roleDef.Hidden)));
contextSource.ExecuteQuery();

IEnumerable listroles = contextSource.LoadQuery(listSource.RoleAssignments.Include(roleAsg => roleAsg.Member, roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name, roleDef => roleDef.Hidden)));
contextSource.ExecuteQuery();

Dictionary<string, string> permisionLists = new Dictionary<string, string>();
foreach (RoleAssignment ra in listroles)
{
RoleDefinitionBindingCollection rdc = ra.RoleDefinitionBindings;
string permission = string.Empty;
foreach (RoleDefinition rdbc in rdc)
{
permission += rdbc.Name.ToString() + ", "; //权限级别
}
permisionLists.Add(ra.Member.Title, permission);
}

//循环输出权限
foreach (var listPermission in permisionLists)
{
Console.WriteLine(listPermission.Key + "..." + listPermission.Value);
}

C# sharepoint client object model 获取Web和List的权限

上一篇:Photoshop处理MM视频照片的杂点


下一篇:C#中工具箱不见了怎么办?