Posted: 18 Nov 2019 7:45 EST Last activity: 11 Mar 2020 17:36 EDT
Current Logged on User to Robot
Can anyone advise what I need to have on my automation in order to determine who the current user of the Pega runtime is.....so not who is logged on to the physical machine (which I would use "CurrentUser for), but the username/group logged into the runtime?
There is a CurrentUser component available in the Toolbox on the Advanced tab. It has a property called "Name" that returns; Domain\Username. You can also use several different static methods from the Global Assembly Cache if you are familiar with that.
I've tried the CurrentUser component, but that only returns the person signed on to the actual machine. I was looking for a component which returned who the actual user of the robot was at the time. The users of the Pega Runtime are signed in as a group, so I'd like to know that setting.
I'm not that familiar with the Global Assembly - are you able to point me to the right place?
To add a static property or nmethod from the Global Assembly Cache (GAC), right-click on an empty area in the Toolbox (with an automation open). Select "Choose Items...". Select the "Pega Robot Static Members" tab. From here, select the "From Global Assembly Cache" check box. Select the "mscorlib" assembly from the combo box. Locate the "Environment" node and check the checkbox next to "UserName" beneath it. Click "Ok". Now you can drag this out to use in an automation.
According to Microsoft, Environment.UserName will return the owner of the current process thread. I do not have a way to test this as my laptop only has a single user. The StackOverflow thread seems to indicate by the poster that it also returns the user running the process.