This code works.It will create a table in an SDE database - recreating it each time. Lists all the domains used in the workspace.
import arcpy
inWorkspaceString = arcpy.GetParameterAsText(0)
arcpy.env.workspace = inWorkspaceString
outTable = "OTHER_ListDomains_tbl"
# Delete old and Create new output table each time
if arcpy.Exists(outTable):
arcpy.Delete_management(outTable)
#
arcpy.CreateTable_management(inWorkspaceString, outTable)
arcpy.AddField_management(outTable, "DomainName", "TEXT", "", "", 255, "", "NULLABLE", "REQUIRED")
arcpy.AddField_management(outTable, "Versioned", "TEXT", "", "", 1, "", "NULLABLE", "NON_REQUIRED")
#
newRows = arcpy.InsertCursor(outTable, "") # Create cursor to store new rows for output table
arcpy.MakeTableView_management(outTable, "outTableView", "", "", "") # Create table view for output table (for searching for existing records)
#
# Create list of domains
desc = arcpy.Describe(inWorkspaceString)
domains = desc.domains
domains.sort() # Sorts list
for domain in domains:
# Write items from list to output table if they don't already exist there
arcpy.SelectLayerByAttribute_management("outTableView", "NEW_SELECTION", "\"DomainName\" = \'" + domain + "\'")
if int(arcpy.GetCount_management("outTableView").getOutput(0)) == 0:
newRow = newRows.newRow()
newRow.DomainName = domain
newRows.insertRow(newRow)
del newRows # Removes lock on output table
Since this discussion was created in 2011, ListDomains—Help | ArcGIS Desktop is probably the best way to get this information in 2017 using Python.
I realize this is a very old thread, but I can't recommend enough X-ray for ArcCatalog for exactly this.