Is it possible to get a list of all UserProfiles (User Sources) available on a Gateway ?
This list can be seen when trying to “Verify an Authentication Profile…” on the “Users,Roles” page on the Gateway.
I was wondering if it can be fetched on the client side.
I’d also find it useful to get a list of user sources on a gateway via scripting to replace the magic strings in listUserSources below and make this function standard for all gateways. Is there something I’m missing?
def listUserSources():
""" Return list of user sources on gateway."""
return ["Hybrid", "default"]
def getFullName(username, userSource=None):
""" Get user's full name from specified user source, or the first one with username when none specified."""
if userSource:
user = system.user.getUser(userSource, username)
else:
for userSource in listUserSources():
user = system.user.getUser(userSource, username)
if user:
break
return user.get("firstname") + " " + user.get("lastname")
There is currently no good way to fetch the list of all configured user source profiles from a script. From gateway scope, you could use this for now, but just know it depends on internal data structures which (though not likely to change in the foreseeable future) may change:
from com.inductiveautomation.ignition.gateway import IgnitionGateway
from simpleorm.dataset import SQuery
from com.inductiveautomation.ignition.gateway.user import UserSourceProfileRecord
query = SQuery(UserSourceProfileRecord.META).ascending(UserSourceProfileRecord.Name)
results = IgnitionGateway.get().getPersistenceInterface().query(query)
userSourceProfileNames = []
for result in results:
userSourceProfileNames.append(result.getName())
return userSourceProfileNames
The latest early access build of 8.1 (8.1.15-b20220131) has implemented a system.user.getUserSources() scripting function which takes no arguments and returns a sequence of objects representing all of the user source profiles configured in the Gateway. Each object has a “name” property, a “description” property, and a “type” property.