More 'secure' way of getting current user.

Started by Thekub, July 19, 2016, 08:14:00 AM

Previous topic - Next topic

Thekub

For a while now I have been merely using Environment("UserName") to identify the person running a given script.  This can be spoofed fairly easily and I'm looking for a more definitive means of getting the user name for the person running the script.

In messing around with this and doing some generic searches I found that calling the Kernel32.dll "GetCurrentProcessID" to get the current PID of the script then using the GetOwner method of Win32_Process appears to be a reliable means.

Just wondering if this is as reliable as it appears or if perhaps there might be a similarly reliable means with less code.   

td

There are multiple ways to get the current user account name.  Here is but one taken form the Tech Database:

Code (winbatch) Select
AddExtender("wwwnt34I.dll")
user =wntGetUser(@default)
Message("I am",user)


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade