Select to view content in your preferred language

Add permissions but no DELETE

281
4
2 weeks ago
kapalczynski
Frequent Contributor

I know that I can add permissions as seen below... But this gives all EDIT permissions... 

I want ADD and UPDATE but NO DELETE... 

Can this be done?

# Import system modules
import arcpy

# Set local variables
datasetName = "c:/Connections/gdb@production.sde/production.GDB.ctgFuseFeature"

# Run ChangePrivileges
arcpy.management.ChangePrivileges(datasetName, "WENDELCLARK", "GRANT", "GRANT")

 

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

According to the help

Change Privileges (Data Management)—ArcGIS Pro | Documentation

The RDBMS equivalent commands for the Edit parameter are Update, Insert, and Delete. All three are granted or revoked simultaneously by the Edit parameter

fine-tuning doesn't appear to be accessable throught this approach


... sort of retired...
0 Kudos
kapalczynski
Frequent Contributor

Dang that's unfortunate 

0 Kudos
DavidPike
MVP Notable Contributor

What about via the DBMS?

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

The trick is to not use arcpy, like @DavidPike suggested. I think this worked for me in the past; give it a shot?

stateGrpDict = {
            "ak": r"[usergroup]",
            "az": r"[usergroup]",
            #...
        }
# Create Table View to grab connection information.
# This part makes more sense in context, but 
# basically i'm grabbing the name of a US State 
#from the database's name via the connection.
db = arcpy.management.MakeTableView(inTbl)[0]
con = db.connectionProperties
conDB = con["connection_info"]["database"]
conDBS = conDB[4:6]
conDS = con["dataset"]
grp = stateGrpDict.get(conDBS, None)

# Apply View, Insert, and Update privileges, but not Delete
# privileges.
# ChangePrivileges() is all or nothing.
# This way, no one can delete the records.
executor = arcpy.ArcSDESQLExecute(IN_WKSPC)
sql = f"GRANT SELECT, INSERT, UPDATE ON {conDS} TO {grp}"
executor.execute(sql)
del executor

 

0 Kudos