I know this is an old post, but I just responded to this same question on
StackOverflow and thought it would be helpful to post here as well.
On the Linux systems that I work with, you can get the user's UID with this:
Note that this is the user id associated with the username used to log-in, not effective user id.