Is User a member of administrators group
Posted: Mon Dec 08, 2014 11:38 pm
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...
http://www.purebasic.com
https://www.purebasic.fr/english/
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_()
Code: Select all
Debug "group-id of current user: " +Str(getgid_())The equivalent in Linux is getuid_() or geteuid_():danielheth wrote:On windows i simply call IsUserAdmin_(), but looking for the linux equivalent...