List of connected users
Using the serveradmin command-line utility, you can send a command to the smb or afp file sharing daemons.  Running the following will return an array of users, including their ipAddress, login time, and account name.

serveradmin command smb:command = getConnectedUsers
serveradmin command afp:command = getConnectedUsers


A typical line of output (for the user name) would appear as

smb:usersArray:_array_index:0:name = "user_foo"
...
smb:usersArray:_array_index:1:name = "user_bar"


If all you are concerned about is the user names,

serveradmin command smb:command = getConnectedUsers | awk -F '"' '/:name/ { print $2 }'


awk -F splits lines on the " , while  /:name/ only operates on lines matching :name.  The $2 takes the second column of text (divided by "), which is the user name.

user_foo
user_bar