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

Last modification:December 24, 2010
稀罕你