AW: How to get the user or his rights?

Tiemo Hollmann TB toolbook at kestner.de
Tue Mar 27 02:43:22 EDT 2012


Great function Ken,
thank you for sharing!
Tiemo

> -----Ursprüngliche Nachricht-----
> Von: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] Im Auftrag von Ken Ray
> Gesendet: Montag, 26. März 2012 20:47
> An: How to use LiveCode
> Betreff: Re: How to get the user or his rights?
> 
> 
> On Mar 26, 2012, at 1:38 AM, Tiemo Hollmann TB wrote:
> 
> > Hi Bob,
> > thanks for your hints.
> > For windows standalones you can set the UAC Execution Level to
> > "require Admin". So LC knows, who's logged in. I wonder, if we can
> > retrieve this information from LC?
> 
> You can get the name of the user that is logged in by checking the
> environment variables $USERNAME (on Windows) and $USER (on Mac). As to the
> user's permission level, this is what I use (watch line wraps):
> 
> 
> function stsIsAdminUser pName, pComputer
>   put stsAdminUserList(pComputer) into tList
>   return (pName is among the lines of tList) end stsIsAdminUser
> 
> function stsAdminUserList pOpt_ComputerName
>   switch (the platform)
>     case "MacOS"
>       put shell("dscl . read /groups/admin") into tData
>       filter tData with "GroupMembership:*"
>       put line 1 of tData into tList  -- strip other lines if there are
any
>       delete word 1 of tList
>       replace space with CR in tList
>       break
>     case "Win32"
>       put "Set objGroup = GetObject(" & q("WinNT://" & pOpt_ComputerName &
> "/administrators,group") & ")" & cr &  \
>           "For Each objMember in objGroup.Members" & cr & \
>           "If tAdminList =" &&  quote & quote && "Then" & cr & \
>           "tAdminList = objMember.name" & cr & "Else" & cr & \
>           "tAdminList = tAdminList + vbCrLf + objMember.name" & cr & \
>           "End If" & cr & \
>           "Next" & cr & \
>           "result = tAdminList" into tScript
> 
>       do script tScript as "VBScript"
>       put the result into tList
>       break
>   end switch
>   return tList
> end stsAdminUserList
> 
> Hope this helps,
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list