|
|
|||||||
Hello everyone, I am trying to deploy software to workstations depending on AD userID. - when i ran this code with domain admin account credentials, it shows UserID of Domain Admin not my UserID(Currently logged in ID) - When i run this code using my credentials, it shows my UserID Should i use other code, or look in registry for currently logged in user and use that value to verify AD information. Thanks for Help $oADSysInfo = CreateObject("ADSystemInfo") $strUser = $oADSysInfo.UserName $oUser = GetObject("LDAP://" + $strUser) $strsAMAccountName = $oUser.sAMAccountName ?$strsAMAccountName |
||||||||
|
|
|||||||
Have you tried the built in macros? ? @UserID |
||||||||
|
|
|||||||
Also check out this thread for the newest .chm version of the manual. It contains all of the built-in commands/functions/macros... http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=202858 |
||||||||
|
|
|||||||
How are you running the code with alternate credentials? (GPO,Runas,Runnas,Sunar, etc) |
||||||||
|
|
|||||||
Explorer.exe should be running in the context as the user you are looking for. Please try this and see if works for you. I would appreciate you replying with your results. |
||||||||
|
|
|||||||
Look at the code below : Code: Function ShowProcessOwner($Exename, optional $remotepc) dim $objWMIService, $objProcess, $objItem, $objOutParams if $remotepc="" $remotepc="." endif $objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2") $objProcess = $objWMIService.ExecQuery("Select * from Win32_Process where Name='" + $exename + "'") For Each $objItem in $objProcess ;-- get the process owner -- $objOutParams = $objWMIService.ExecMethod( $objitem.path_, "getOwner" ) "owner : " $objOutParams.domain + "\" + $objOutParams.user ? Next Endfunction this is a full WMI solution |
||||||||
|
|
|||||||
I finally had a minute to revisit this. I took ChristopheM's version, tweaked it a bit and posted to UDFs. GetProcessOwner() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=204086&Main=204086#Post204086 |