This forum has been archived. All content is frozen. Please use KDE Discuss instead.

getting the username and (main) group, the KDE way

Tags: None
(comma "," separated)
fluca1978
Registered Member
Posts
81
Karma
0
OS
Hi all,
even if browsing some source code I cannot find a KDE-style way of getting the username and main group of the current logged in user. Is it possible that there is not another way than looking directly at the result of getpwuid and getgrouplist?
DaSheep
Registered Member
Posts
95
Karma
1
OS
Try looking at the kuser code.
fluca1978
Registered Member
Posts
81
Karma
0
OS
montfras wrote:Try looking at the kuser code.


Thanks, it was so simple!
DaSheep
Registered Member
Posts
95
Karma
1
OS
Do you mind sharing your findings?
You got me interested as well, and it would save me 10 minutes of searching 8)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The code in question is likely the KUser class. You can find the api documentation for it at http://api.kde.org/


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
fluca1978
Registered Member
Posts
81
Karma
0
OS
montfras wrote:Do you mind sharing your findings?
You got me interested as well, and it would save me 10 minutes of searching 8)


You can create a new KUser object that will be "attached" to the running user, and therefore you have access to the uid/gid and login name, as well as the list of group names.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft