How to use GrantIdentity ?


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

var myidentity = Aras.Server.Security.Identity.GetByName("My Identity");
bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity();

try {
	/**************YOUR SPECIAL CODE HERE***************/
    if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(myidentity);

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 ?

using (CCO.Permissions.GrantIdentity(Aras.Server.Security.Identity.GetByName("My Identity")))
	/**************YOUR SPECIAL CODE HERE***************/

Thank you in advance for your answer.

  • 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.

  • Hi,

    In PE_AffectedItemFloat, I found this:

    Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
    IDisposable elevatedPermissionsScope = CCO.Permissions.GrantIdentity(plmIdentity);
    // Revoke 'Aras PLM' permissions
    return this;

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

    So, this should work well:

    using (CCO.Permissions.GrantIdentity(Aras.Server.Security.Identity.GetByName("My Identity")))
    	/**************YOUR SPECIAL CODE HERE***************/

  • 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.Grimacing

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

  • I don't know. I didn't find it.