Author Topic: Reference: AccessMask property for PermissionDescriptor class  (Read 2228 times)

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
Reference: AccessMask property for PermissionDescriptor class
« on: August 29, 2018, 12:31:58 AM »
Hello,

I just had to figure something out and thought I would share it with the community as I was unable to find the information anywhere.

Imagine for a moment the different types of permissions you can grant on a folder or object in the configuration layer:
[list]
[li]No Access[/li]
[li]Read[/li]
[li]Create[/li]
[li]Change[/li]
[li]Execute[/li]
[li]Delete[/li]
[li]Read Permissions[/li]
[li]Change Permissions[/li]
[li]Read and Execute[/li]
[/list]

Now imagine you are using PSDK to obtain a reference to a folder or object.  Most classes have a RetrievePermissions method hanging off of them (an example would be CfgFolder.RetrievePermissions()).  RetrievePermissions returns an object of type PermissionDescriptor.  PermissionDescriptor has a field/property hanging off of it named AccessMask but there is no documentation around what AccessMask.

The AccessMask property is an integer, here is a mapping of access privileges to integer values:
0 = No Access
1 = Read
2 = Create
4 = Change
8 = Execute
16 = Delete
32 = Read Permissions
64 = Change Permissions

The integer returned by AccessMask will be a sum of the enumeration above.

If there is no access the value would be 0.

If there was only read access the value would be 1.

If there was read and create access the value would be 3.

Change and Execute access the value would be 12.

If all access is granted the value would be a sum of all the numbers, 127.

With this information you will be able to programatically understand permissions on configuration layer objects.

Regards,
Andrew

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Reference: AccessMask property for PermissionDescriptor class
« Reply #1 on: August 29, 2018, 12:26:56 PM »
Nice info!
Thanks for sharing it!