getting uid or username of logged in user

  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Joined: Jul 28, 2003
  • Posts: 774
  • Loc: Brisbane, Australia
  • Status: Offline

Post September 21st, 2004, 11:12 pm

Hi
I am writing a C++ app and i need a way to get the the user ID and the user name of the currently logged in user. Any ideas?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 21st, 2004, 11:12 pm

  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Joined: Jul 28, 2003
  • Posts: 774
  • Loc: Brisbane, Australia
  • Status: Offline

Post September 22nd, 2004, 1:52 am

Here's how I did it:



#include <unistd.h>


int uid = getuid();


I have a code snippet to get the name but I haven't tested it yet.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 37 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.