CRM中代码自动共享

samool 发布1 条评论15325 阅读

AI摘要

本文介绍了在CRM中实现代码自动共享的方法。通过创建SecurityPrincipal对象、设置PrincipalId、创建PrincipalAccess对象、设置AccessMask为读权限、创建TargetOwnedAccount对象、设置EntityId、创建GrantAccessRequest对象并执行,可以实现对特定用户授予对特定账户的访问权限。

// Create the SecurityPrincipal Object
    SecurityPrincipal principal = new SecurityPrincipal();
    principal.Type = SecurityPrincipalType.User;

    // PrincipalId is the Guid of the user to whom access is being granted
    // SDK:principal.PrincipalId = new Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");
    principal.PrincipalId = otherUserId;

    // Create the PrincipalAccess Object
    PrincipalAccess principalAccess = new PrincipalAccess();

    // Set the PrincipalAccess Object's Properties
    principalAccess.Principal = principal;

    // Gives the principal access to read
    principalAccess.AccessMask = AccessRights.ReadAccess;
   
    // Create the Target Object for the Request
    TargetOwnedAccount target = new TargetOwnedAccount();

    // EntityId is the Guid of the account access is being granted to
    // SDK:target.EntityId = new Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");
    target.EntityId = created.id;

    // Create the Request Object
    GrantAccessRequest grant = new GrantAccessRequest();

    // Set the Request Object's properties
    grant.PrincipalAccess = principalAccess;
    grant.Target = target;

    // Execute the Request
    GrantAccessResponse granted = (GrantAccessResponse)service.Execute(grant);

  1. 01KDBOSS回忆录12025-02-02
  2. 02MSCRM禁用标签页内所有组件2012-02-07
  3. 03mscrm4屏幕ctrl+s热键2011-01-07
  4. 04mscrm4隐藏grid页上的按钮2011-01-07
  5. 05mscrm 将自定义的视图在sitemap中显示2010-12-28
  6. 06mscrm4 用js阻止表单保存2010-12-28
  7. 07MSCRM4 ISV.Config2010-12-28
  8. 08控制MSCRM4菜单栏2010-12-28
  9. 09MSCRM4 隐藏按钮方法2010-12-24
  10. 10MSCRM4获取选择记录的guid2010-12-24
COMMENTS / 一纸留言

读者留言 1 条

一纸留言,便是山水间的一次相逢。

  1. 不错,我学习了,谢谢分享

WRITE A COMMENT

写下你的留言