Is User a member of administrators group
-
danielheth
- New User

- Posts: 9
- Joined: Mon Dec 01, 2014 5:12 pm
- Location: Arkansas
- Contact:
Is User a member of administrators group
is there a way to tell if the user running my program is an administrator or not? On windows i simply call IsUserAdmin_(), but looking for the linux equivalent...
Re: Is User a member of administrators group
Not sure but you could try to write a file to a directory that requires root access
Code: Select all
Procedure IsUserAdmin_()
Protected rand.l,file.s
rand = Random($FFFFFF)
file.s = MD5Fingerprint(@rand,4)
If CreateFile(0,"/etc/"+file)
CloseFile(0)
DeleteFile("/etc/"+file)
ProcedureReturn 1
EndIf
EndProcedure
Debug IsUserAdmin_()
Windows 11, Manjaro, Raspberry Pi OS


Re: Is User a member of administrators group
Hi,
this might be what you're looking for:Source: Shows group-id of current user
Please see Oma's http://www.chabba.de/LinuxAPI.html /Misc for more
@idle ~ I like solutions like yours
greets ~ Vera
this might be what you're looking for:
Code: Select all
Debug "group-id of current user: " +Str(getgid_())Please see Oma's http://www.chabba.de/LinuxAPI.html /Misc for more
@idle ~ I like solutions like yours
greets ~ Vera
Two growing code-collections: WinApi-Lib by RSBasic ~ LinuxAPI-Lib by Omi
Missing a download-file on the forums? ~ check out this backup page.
Missing a download-file on the forums? ~ check out this backup page.
Re: Is User a member of administrators group
The equivalent in Linux is getuid_() or geteuid_():danielheth wrote:On windows i simply call IsUserAdmin_(), but looking for the linux equivalent...
http://www.purebasic.fr/english/viewtop ... 64&start=1
http://www.purebasic.fr/german/viewtopi ... 39&start=3

