Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am managing data distribution via an ArcSDE Oracle gdb to a number of users (schemas?), each of which can only have read only access to datasets they have requested access to, and have then been licensed to see - due to the confidential nature of the data.

Currently I keep these privileges in a spreadsheet as 0, 1, or 2 for each user, and with a Python program, I then update each dataset in the SDE to match the privileges in the spreadsheet using the ArcGIS "Change Privileges" tool.

However, this means I am currently running the change privileges on all SDE datasets, when in reality only a handful may actually need be changed, which is then taking a lot longer than it really needs to. So I am looking for a way to find out what privileges each dataset already has, to know if they do need to be updated or can be skipped, probably with a custom function (nothing Oracle please), as in a simplified example of my existing code below:

import arcpy

#  New function here 
def CheckPrivileges(sde_fc, user):
    return privileges_value  #  e.g. 'Select'

#  Input SDE and spreadsheet paths
sde = r'SDEConnectionPath'
in_xl = r'SpreadsheetSheetPath'

#  Dictionary to convert 0, 1, 2 values from spreadsheet to privilege lists
new_privileges = {"0": ["REVOKE",  "REVOKE"], "1": ["GRANT",  "AS_IS"], "2": ["GRANT",  "GRANT"]}

#  A second dictionary to check against the returned value from the CheckPrivileges function, 
#  but using the same values from the spreadsheet e.g.    
privileges_check = {"0": "", "1": "Select", "2": "All"}  #  (This is almost certainly incorrect)

#  In the spreadsheet, each user has a column with the 0, 1, 2 privilege values e.g.
user = 'USER1'

#  Search cursor with each dataset and the users privileges.
rows = arcpy.da.SearchCursor(in_xl, ['SDE_DATASET', user])
for row in rows:

    #  Path to SDE dataset having privileges altered.
    sde_fc = sde + '\\' + row[0]

    #  Pulls out the correct privilege values from the dictionaries.
    user_privs = new_privileges[str(row[1])]

    check_privs = privileges_check[str(row[1])]

    #  This is where I would call the new function I need e.g.
    current_privs = CheckPrivileges(sde_fc, user) 

    #  And then check against what it should be according to the dictionary.
    if current_privs != check_privs:

        #  If not equal, then amend privileges, otherwise continue to the next row
        arcpy.ChangePrivileges_management(sde_fc, user, user_privs[0], user_privs[1])

If anybody has any ideas of how to construct the missing "CheckPrivileges", I would love to hear them. Apologies in advance if this isn't enough detail, or my terms aren't quite correct, as I'm new to ArcSDE, and also to this site itself.


share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.