Jump to content

Recommended Posts

Posted

Hi guys, I've been trying different methods of getting dsa.msc (Active Directory Users and Computers) running using AutoIt through CyberArk.  I've tried several different methods and just can't seem to get it to launch when I test it locally and explicitly filling in the password and username variables.  I even tried creating  batch file that would launch dsa.msc and call that batchfile with the Runas command within AutoIt, but no luck.  My current script is:

 

Dsamsc()

Func Dsamsc()

   Local $sUserName = "actualusername"
   Local $sPassword = "actualpassword>"

   ;Command to run batch file that will run dsa.msc as target user from CyberArk
   Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, "dsamsc.bat", "", @SW_SHOWMAXIMIZED)

   WinWait("[CLASS:MMCMainFrame]", "", 10)

   ProcessClose($iPID)

EndFunc

I've tried changing the launch command to 'c:\windows\system32\mmc.exe "dsa.msc"' as well with no luck.

Any help or advice in getting this done would be greatly appreciated.

Posted (edited)

Why automate the GUI? Use my AD UDF to directly access Active Directory.

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I'm doing this through CyberArk so I don't want the users ever having access to the actual password themselves and it would allow the session to be recorded for review.

Posted

Does CyberArk provide an API to handle such cases?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 1/18/2018 at 8:42 PM, water said:

Does CyberArk provide an API to handle such cases?

Expand  

Not a built in one that I'm aware of.  I'm creating a connection component utilizing AutoIt, which they seem to heavily recommend for things like this.

Posted

I figured out what I was doing wrong here.  I had to add in the logon flag as a 2 after the $sPassword variable.  Once I did that it processed successfully even with MMC and DSA.msc defined.  So basically I changed below:

RunAs($TargetUsername, $TargetDomain, $TargetPassword, 2, 'C:\Windows\System32\mmc.exe "C:\Windows\System32\dsa.msc"', "", @SW_SHOWMAXIMIZED)

Hope this helps someone else.

 

  • 1 year later...
Posted (edited)

I'm looking to do the same but for BeyondTrust instead of CyberArk. I want to launch mmc with the AD Snap-in and have BeyondTrust pass credentials to the AutoIT exe.

This is the script I have thus far:

#include <AutoItConstants.au3>
#include <Constants.au3>
If $CmdLine[0] <> 3 Then
   MsgBox($MB_OK, "Usage", "mmc_launch <domain> <username> <password>")
Else
   mmc_launch($CmdLine[1], $CmdLine[2], $CmdLine[3])
EndIf

mmc_launch()

Func mmc_launch($domain, $username, $password)

    ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
    Local $iPID = RunAs($Username, $Domain, $Password, 2, 'C:\Windows\System32\mmc.exe "C:\Windows\System32\dsa.msc"', "", @SW_SHOWMAXIMIZED)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the process using the PID returned by RunAs.
    ProcessClose($iPID)
EndFunc
 
Edited by Jos
  • Developers
Posted (edited)
  On 2/6/2019 at 8:29 PM, chrweav86 said:

mmc_launch()

Expand  

This line probably does that. What is it doing there?

It is way easier to run it from SciTE first before compiling. 
...and even better is to load the Full SciTE4AutoIt3 version which will run au3check before the run and tell you about these things:

>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:D:\Development\AutoIt3\programs\test\test.au3
"D:\test.au3"(12,47) : error: mmc_launch() called by a previous line with 0 arg(s). Min = 3. First previous line calling this Func is 7.
Func mmc_launch($domain, $username, $password)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Development\AutoIt3\programs\test\test.au3 - 1 error(s), 0 warning(s)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I've got it working now. How do I elevate the script to run elevated with respect to UAC?

I can get it to run with BeyondTrust with UAC turned off on the server.

I removed the session killer and the mmclaunch() form the script and it works now.

  • 1 year later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...