Hi @sivakr2 ,
To validate AEM group permissions and export them to CSV, you can use a Groovy script via the AEM Groovy Console, which is the most effective and widely used method for tasks like this in AEM.
1. Install AEM Groovy Console (if not already installed).
GitHub: https://github.com/icfnext/aem-groovy-console
2. Use this Groovy script in Groovy Console:
import org.apache.jackrabbit.api.security.user.Group
import com.day.cq.security.AccessControlUtil
import au.com.bytecode.opencsv.CSVWriter
def session = resourceResolver.adaptTo(Session)
def userManager = resourceResolver.adaptTo(UserManager)
def groups = ["group1", "group2"] // Your AEM group names
def writer = new StringWriter()
def csv = new CSVWriter(writer)
csv.writeNext(["Group", "Path", "Privileges"])
groups.each { g ->
def group = userManager.getAuthorizable(g)
if (group instanceof Group) {
AccessControlUtil.getAccessControlEntries(session, "/").findAll {
it.principal.name == g
}.each {
csv.writeNext([g, it.path, it.privileges*.name.join(", ")])
}
}
}
println writer.toString()
Run the script, copy the output, and save as .csv.
To include nested groups, you'd need recursion in getAllPermissions.
If groups are spread across different paths (/home/groups/site, etc.), you can query them dynamically.
You can also run this as a scheduled task if regular exports are needed.
Regards,
Amit