• Dynamics CRM 365 查询客户共享给那些用户的方法


    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);
  • 相关阅读:
    groovy的效率问题
    强大的模板引擎开源软件NVelocity
    每个人应该知道的NVelocity用法
    NVelocity语法常用指令
    CS0016: 未能写入输出文件“c:WINDOWSMicrosoft.NETFramework.。。”--“拒绝访问
    C# 数组基础知识
    c#中的 数组
    网络编程之webclient和httpwebrequest的使用
    HttpWebRequest和WebClient的区别
    C#如何使用SplitContainer控件实现上下分隔
  • 原文地址:https://www.cnblogs.com/parkerchen/p/16384867.html
Copyright © 2020-2023  润新知