Forum Discussion

miraks's avatar
miraks
Ideator I
3 years ago

How to use GrantIdentity ?

Hi,

On ARAS R12, in server methods, I needed to grant temporary some rights.
For that, I did something like this:

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:72a39175-e3c1-4aa3-9737-c3edc266744d:type=csharp&text=var%20myidentity%20%3D%20Aras.Server.Security.Identity.GetByName%28%22My%20Identity%22%29%3B%0D%0Abool%20PermissionWasSet%20%3D%20Aras.Server.Security.Permissions.GrantIdentity%28%29%3B%0D%0A%0D%0Atry%20%7B%0D%0A%09%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AYOUR%20SPECIAL%20CODE%20HERE%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0Afinally%0D%0A%7B%0D%0A%20%20%20%20if%20%28PermissionWasSet%29%20Aras.Server.Security.Permissions.RevokeIdentity%28myidentity%29%3B%0D%0A%7D]

Due to deprecated API, on ARAS R19, I need to use CCO.Permissions.GrantIdentity but this method doesn't return a boolean to know if the identity has been granted or not.

How should I do ? When and how to do the RevokeIdentity ?

Is this enough ?

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:fe51a9bf-6590-497f-ada6-3812e157228b:type=csharp&text=using%20%28CCO.Permissions.GrantIdentity%28Aras.Server.Security.Identity.GetByName%28%22My%20Identity%22%29%29%29%0D%0A%7B%0D%0A%09%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AYOUR%20SPECIAL%20CODE%20HERE%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%7D]

Thank you in advance for your answer.

4 Replies

  • I don´t use R19, but I am highly interested in this topic!

    How does Aras solve this one in the Method "PE_AffectedItemFloat" or "PE_ChangeItemTransition"? New variant should be visible in the beginning in the code if they don´t have changed the code completely.

    • miraks's avatar
      miraks
      Ideator I

      Hi,

      In PE_AffectedItemFloat, I found this:

      [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:f4b854ff-9a17-4a56-a6cf-8ab991a8ace6:type=csharp&text=Aras.Server.Security.Identity%20plmIdentity%20%3D%20Aras.Server.Security.Identity.GetByName%28%22Aras%20PLM%22%29%3B%0D%0AIDisposable%20elevatedPermissionsScope%20%3D%20CCO.Permissions.GrantIdentity%28plmIdentity%29%3B%0D%0A%0D%0A...%0D%0A%0D%0A%2F%2F%20Revoke%20%27Aras%20PLM%27%20permissions%0D%0AelevatedPermissionsScope%3F.Dispose%28%29%3B%0D%0A%0D%0Areturn%20this%3B]

      So, the temporary grant is revoked with the call to Dispose.

      So, this should work well:

      [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:c2616d20-184c-4730-8993-bbddd2cf0940:type=text&text=using%20%28CCO.Permissions.GrantIdentity%28Aras.Server.Security.Identity.GetByName%28%22My%20Identity%22%29%29%29%0D%0A%7B%0D%0A%09%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AYOUR%20SPECIAL%20CODE%20HERE%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%7D]

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        Your "using" variant sounds right for me! I already fear the amount of Methods I have to update manually once there is a new open release.[emoticon:4b473fb4671244b2a5887318abe9e44a]

        Is there somewhere an overview of the code impact due to .NET Core changes?