Checking current user privileges for ArcDE dataset with ArcPy

I have found that ArcSDESQLExecute allows a query against ALL_TAB_PRIVS while using an existing SDE connection.

This sample implementation:

def get_privileges(sde, owner, table):
    privileges  = {"edit": set(), "view": set()}
    command = """
        select PRIVILEGE, GRANTEE
        from ALL_TAB_PRIVS 
        where TABLE_NAME = '{0}'
        and TABLE_SCHEMA = '{1}'""".format(table, owner)
    executor = arcpy.ArcSDESQLExecute(sde)
    result = executor.execute(command)
    for row in result:
        if row[0] == "SELECT":
            privileges["view"].add(row[1])
        elif row[0] in ("UPDATE", "INSERT", "DELETE"):
            privileges["edit"].add(row[1])
    return privileges

Can be used like this:

sde = r"C:\path\to\connection.sde"
owner = "OWNER_NAME"
table = "TABLE_NAME"

get_privileges(sde, owner, table)

# output:
{
    'edit': set([u'USER1']),
    'view': set([u'USER1', u'USER2', u'USER3'])
}

import arcpy, os, pyodbc
def GetPrivileges(table):
   cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=user;PWD=password')
   cursor = cnxn.cursor()
   cursor.execute("EXEC sp_helprotect '" + table + "'")
   rows =cursor.fetchall()
   privileges = []
   for row in rows:
       privileges.append(row.Grantee)
   return privileges

arcpy.env.workspace =sdecon
for fc in arcpy.ListFeatureClasses():
    desc = arcpy.Describe(fc)
    table = desc.BaseName
    print table, GetPrivileges(table)