[IGN-3498]Change language according Active Directory logged user

Hello guys! I don't know if it's possible, but i need to change the language automatically every time that I logged-in using Active directory.

Put this code in Client event Script - Startup

userName = system.security.getUsername()
user = system.user.getUser("", userName)

Without Active Directory I use a simple script and I configure the language inside each user. It's simple, but when i use Active Directory, I don't know how read the language

I found a topic with the same question, but it didn't have any answers.
Have some way to do this?

Did you ever figure out how to do this? I'd like to do the same, but in Ignition 8.1 Perspective. I also could get it to work for internal user sources, but not for AD. I got as far as setting the preferredLanguage attribute on my user in the Active Directory, but I can't seem to read it from Ignition.

For anyone else searching for a solution, I found a bit of a hacky workaround that at least works for 8.1.

It looks like only a subset of the Active Directory attributes are accessible from Ignition and they're by default set up to populate certain default properties of a user in Ignition. However, if you go into the advanced properties of the Active Directory, there's nothing to stop you from changing what attribute they're actually using. So, if you change one of them from its default to preferredLanguage, you can access that attribute via the property it's supposed to represent.

For example, you can override the phone contact info like this:

Then use the phone contact information in your script to access the language:

user = system.user.getUser("", userName)
# Default to english
language = "en"
for contactInfo in user.getContactInfo():
	# Phone number has been mapped to preferredLanguage
	if contactInfo.getContactType() == "phone":
		language = contactInfo.getValue()

Note that the above is a fragment - get userName and set your locale however you like for your application. For me, I put a binding on the session prop locale pointed at the session prop auth.user, used value.userName to get my username, and returned language to set the locale.


Adding the ability to fetch arbitrary AD attributes is on our roadmap :slight_smile: