Yes, but it will depend on your xhost
settings. So, if you have connected as userB to a machine that is running an X session owned by userA, you will need to do two things:
userA must allow you access:
userA@foo $ xhost +
You need to set your
DISPLAY
variable to the remote display:userB@foo $ export DISPLAY=:0;
Now userB will be able to run graphical programs.