Jump to content

DSA.MSC


LucasZ
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Does CyberArk provide an API to handle such cases?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

35 minutes ago, water said:

Does CyberArk provide an API to handle such cases?

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
Share on other sites

  • Moderators

@chrweav86 That's great you told us what you want. How about filling us in on what problem you're running into (error code, etc. etc.)? :)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers
1 hour ago, chrweav86 said:

mmc_launch()

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.
  :)

Link to comment
Share on other sites

  • 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
 Share

  • Recently Browsing   0 members

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