Lazarus

Programming => Operating Systems => Linux => Topic started by: a.atalla on July 07, 2010, 12:42:07 pm

Title: how to get the username
Post by: a.atalla on July 07, 2010, 12:42:07 pm
i need the user name to use in my application
i couldnot found the function that returns the user-name  in linux
Title: Re: how to get the username
Post by: theo on July 07, 2010, 12:55:34 pm
GetEnvironmentVariable('USER');         
Title: Re: how to get the username
Post by: typo on July 07, 2010, 01:44:37 pm
GetEnvironmentVariable('USERNAME');   
Title: Re: how to get the username
Post by: a.atalla on July 07, 2010, 04:15:24 pm
GetEnvironmentVariable('USER');         

that works ,but now my application will run with root priviliage so that function will return "root"  as the user name
is there any way i can list all the computer users "not only the current user" ?
Title: Re: how to get the username
Post by: theo on July 07, 2010, 04:49:58 pm
What do you want to achieve?
Sounds like you don't know yourself ;-)

http://forum.lazarus.freepascal.org/index.php/topic,9770.msg48175.html#msg48175
Title: Re: how to get the username
Post by: a.atalla on July 07, 2010, 05:01:20 pm

GetEnvironmentVariable('USER');         
this one was what i'm looking for but now i need another thing

my application will run on the user machine with root privilege ,and it will do some admin stuff on other users account ,so i need to know what the other users that use the computer

i wish that is clear

does the post u linked belongs to my question?
Title: Re: how to get the username
Post by: theo on July 07, 2010, 05:11:41 pm
does the post u linked belongs to my question?

Yes.
Title: Re: how to get the username
Post by: Laksen on July 07, 2010, 07:49:54 pm
It's easy.

Take a look at the users unit in the users fpc package. It contains everything you need. GetUserList, and GetUserData combined with FpGetuid from baseunix sounds like what you want :)

That's ofcourse a very unix specific unit :)
TinyPortal © 2005-2018