Sign in to follow this  
Followers 0
flitcraft33

Determining the REAL User that is logging in

5 posts in this topic

I am trying to use an AutoIT script to resolve a log in issue with an access control system. The problem that I have is that the scipt is launced by the access control system using the SYSTEM user credentials. I want to get at the name of the user who is actually logging in. If I use the @Username variable, I get "SYSTEM" returned. So what I need is some way to get at the user who is actually presenting the credentials, not the user user that invokes the script.

Any help would be appreciated.

Thanks,

Dan Sichel

daniels@ponderosatel.com

Share this post


Link to post
Share on other sites



I am trying to use an AutoIT script to resolve a log in issue with an access control system. The problem that I have is that the scipt is launced by the access control system using the SYSTEM user credentials. I want to get at the name of the user who is actually logging in. If I use the @Username variable, I get "SYSTEM" returned. So what I need is some way to get at the user who is actually presenting the credentials, not the user user that invokes the script.

Any help would be appreciated.

Thanks,

Dan Sichel

daniels@ponderosatel.com

Here's the snippet I use:

$sLoggedInUser = ""
$sLoggedInDomain = ""
$sResults = ""
$strComputer = "."
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
If IsObj($objWMIService) Then
    $colComputer = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

    For $objComputer In $colComputer
        $sLoggedInUser = $objComputer.UserName
    Next
    If StringInStr($sLoggedInUser,"\") Then
        $iSplit = StringInStr($sLoggedInUser,"\")
        $sLoggedInDomain = StringTrimRight($sLoggedInUser,(StringLen($sLoggedInUser) - $iSplit)+1)
        $sLoggedInUser = StringTrimLeft($sLoggedInUser,$iSplit)
    EndIf

    If $sLoggedInDomain <> "" Then $sResults &= "Logged in domain: " &$sLoggedInDomain &@CRLF
    If $sLoggedInUser <> "" Then $sResults &= "Logged in user: " &$sLoggedInUser & @CRLF
    $sResults &= "@UserName value: " &@UserName &@CRLF
    ConsoleWrite($sResults)
Else
    ConsoleWrite("Unable to connect to WMI Service" & @CRLF)
EndIf

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

That seems to have done the trick. Thank you VERY much. How is it that it is getting the actual user, not the user that owns the autoit process? And is it the user's domain log in or local machine? I do not know much of anything about the WIMIservice query that you use and how that gets me where I need to be, I just know that cutting and pasting it into a script seems to have worked!

If you have a moment and wouldn't mind, either pointing me to somplace that describes this a bit or explaining it directly would also be much appreciated.

Thanks again for the quick and accurate help.

Dan Sichel

Share this post


Link to post
Share on other sites

If you have a moment and wouldn't mind, either pointing me to somplace that describes this a bit or explaining it directly would also be much appreciated.

In the case of this script, I'm pretty sure that I just grabbed the core functionality straight from Microsoft's TechNet Script Center and modified it accordingly for AutoIt. There are a few links in the sidebars (under Resources) with some of the original language references.

If you just want to go straight to the "script repository" try -> here.


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

hey monamo, i ran this script and only get accurate results when i am the person logged in to the remote machine.

i have local admin access on all machines on the domain...

any ideas?

Edited by gcue

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0