CRM中代码自动共享

作者: 傻猫    分类: 搞软件     发布时间: 12-24 14:59    浏览次数: 7803     1 条留言

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

Tags: mscrm, 共享

仅有一条评论 »

  1. Ev1n

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

添加新评论