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)
system.util.setLocale(user.get('language'))

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?