The library routine C$GETENV can be called on a local or client machine to get the user name. Here's an example. The "Client" keyword will be ignored if the program isn't running in thin client mode:
move "user.name" to varname call client "C$GETENV" using varname, ws-username