apply sde privileges to another FC

10-10-2017 02:10 PM
Occasional Contributor III

Hello everyone,

I want to read all the feature classes from SDE database A and apply all the privileges to the same feature class in SDE database B.

arcpy.env.workspace = "c:/base"# Use the ListFeatureClasses function to return a list of#  shapefiles.featureclasses = arcpy.ListFeatureClasses()# Copy shapefiles to a file geodatabasefor fc in featureclasses:
  ??? How do I get the current privileges for this FC ??
0 Kudos
2 Replies
MVP Esteemed Contributor

before you go too far with providing code samples, yours is not readable in its current form

Code Formatting the Basics ++ will get you started and you haven't indicated how much arcpy you are familiar with and why you have to do this via code in the first place, and can you accomplish what you want to do manually?  If you have a current workflow that uses tools in arctoolbox, then the coding is simple.  Processes, methods and properties that don't exist in arctoolbox can be accessed through arcpy... some, but not all.  So if you could fill in the gaps, that would be great

0 Kudos
Regular Contributor

Hi Jose,

Have a look at this thread in GIS Stack Exchange:

Checking current user privileges for an SDE dataset with Python/arcpy - Geographic Information Syste... 

There's a nice function that will return a python dictionary showing the roles having view and edit permissions given a certain SDE connection, DB owner, and table name. Assuming the feature class names in sde1 are the same as in sde2, you could:

  1. Use ListFeatureClasses to list all the feature classes in sde1
  2. Use the function linked above to get a list of the viewers and editors for that dataset
  3. Use Change Privileges to apply those same permissions to the dataset in sde2

The key things would be to parse the feature class names to separate the owner and table name (they are in the format OWNER.TABLENAME), read the lists of viewers and editors out of the dictionary returned by the get_privileges function, and successfully pass the names to the right parameter of the Change Privileges tool.