flitcraft33 Posted September 15, 2008 Share Posted September 15, 2008 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 Link to comment Share on other sites More sharing options...
Monamo Posted September 15, 2008 Share Posted September 15, 2008 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.comHere'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] Link to comment Share on other sites More sharing options...
flitcraft33 Posted September 15, 2008 Author Share Posted September 15, 2008 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 Link to comment Share on other sites More sharing options...
Monamo Posted September 16, 2008 Share Posted September 16, 2008 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] Link to comment Share on other sites More sharing options...
gcue Posted September 16, 2008 Share Posted September 16, 2008 (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 September 16, 2008 by gcue Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now