1 Reply Latest reply on Dec 3, 2019 1:34 PM by Geraldine Zanolli

    Using TSC to get content permissions

    Chadd McNicholas

      Hi! Fist time posting to the Developer Forum.  Documentation for pulling permissions with TSC haven't been published yet. So I decided to share some sample code for pulling permissions for a Data Source (can easily be modified for a Workbook, too).  I hope some folks find this useful.

      (Excuse my poor python skills )




      ds = server.datasources.get_by_id('<your data source LUID')
      permissions = ds.permissions
      i = -1
      for rule in permissions:
          i += 1
          group_user_type = permissions[i].grantee.tag_name
          group_user_id = permissions[i].grantee.id
          group_user_capabilities = permissions[i].capabilities
          if group_user_type == 'user':
              user_item = server.users.get_by_id(permissions[i].grantee.id)
              group_user_name = user_item.name
          elif group_user_type == 'group':
              for group_item in TSC.Pager(server.groups):
                  if group_item.id == group_user_id:
                      group_user_name = group_item.name
          print('Type: %s\tName: %s\tCapabilities: %s' %(group_user_type, group_user_name, group_user_capabilities))