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);
}