Last active
August 29, 2015 13:58
-
-
Save mickle00/9939668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import xmltodict | |
import glob | |
def getProfiles(): | |
profiles = glob.glob('profiles/*.profile') | |
rows = getCSVShell(profiles[0]) | |
for profile in profiles: | |
addColumns(profile, rows) | |
writeCSV(rows) | |
def writeCSV(rows): | |
outputFile = open('PROFILE' + '_FLS.csv', 'w') | |
for row in rows: | |
outputFile.write(row + '\n') | |
outputFile.close() | |
def addColumns(profile, rows): | |
f = open(profile, 'r') | |
j_dict = xmltodict.parse(f.read()) | |
fields = j_dict['Profile']['fieldPermissions'] | |
profile_name = profile.replace(' ', '_') | |
profile_name = profile_name.replace('profiles/', '') | |
profile_name = profile_name.replace('.profile', '') | |
rows[0] += ',' + profile_name | |
fieldIndex = 1 | |
for fieldPermission in fields: | |
rows[fieldIndex] += ',' + getFLS(fieldPermission) | |
fieldIndex += 1 | |
return rows | |
def getFLS(fieldPermission): | |
if fieldPermission['editable'] == 'true': return 'EDIT' | |
if fieldPermission['readable'] == 'true': return 'READ' | |
return '-' | |
def getCSVShell(profile): | |
rows = ['OBJECT,FIELD'] | |
f = open(profile, 'r') | |
j_dict = xmltodict.parse(f.read()) | |
fields = j_dict['Profile']['fieldPermissions'] | |
for fieldPermission in fields: | |
obj, fld = fieldPermission['field'].split('.') | |
rows.append(obj + ',' + fld) | |
return rows | |
getProfiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT Parent.Profile.Name, SobjectType, Field,PermissionsEdit,PermissionsRead,SystemModstamp | |
FROM FieldPermissions | |
WHERE sObjectType = 'Account' | |
AND Parent.Profile.Name = 'System Administrator' | |
ORDER BY SystemModStamp DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment