IOrganizationService adminservice = getorgan(); List<UserMode> systemList = getSystemuser(adminservice); var accList = GetAccountList(adminservice); int idex = 0; foreach (var en in accList) { idex++; EntityReference enf = en.ToEntityReference(); RetrieveSharedPrincipalsAndAccessRequest shareRequest = new RetrieveSharedPrincipalsAndAccessRequest(); shareRequest.Target = enf; RetrieveSharedPrincipalsAndAccessResponse shareResponse = (RetrieveSharedPrincipalsAndAccessResponse)adminservice.Execute(shareRequest); if (shareResponse.PrincipalAccesses != null) { foreach (PrincipalAccess pa in shareResponse.PrincipalAccesses) { var sys = systemList.Find(x => x.id == pa.Principal.Id.ToString()); if (sys == null) { continue; } string accM = pa.AccessMask.ToString(); list.Text += @"<tr> <td>" + en.GetAttributeValue<string>("name") + @"</td> <td>" + en.GetAttributeValue<EntityReference>("ownerid").Name + @"</td> <td>" + sys.name + @"</td> <td>" + accM + @"</td> </tr>"; } } }
前端:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <style type="text/css"> td{ border:1px solid #ddd; padding:4px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table style="border-collapse:collapse;"> <tr> <td>客户名称</td> <td>负责人</td> <td>共享用户</td> <td>共享权限</td> </tr> <asp:Literal ID="list" runat="server"></asp:Literal> </table> </div> </form> </body> </html>
温馨提示,主要代码端在这里,所以有几个函数并没有提供
etrieveSharedPrincipalsAndAccessRequest shareRequest = new RetrieveSharedPrincipalsAndAccessRequest(); shareRequest.Target = enf; RetrieveSharedPrincipalsAndAccessResponse shareResponse = (RetrieveSharedPrincipalsAndAccessResponse)adminservice.Execute(shareRequest);