Jump to content

Opening Active Directory


jgq85
 Share

Recommended Posts

I'm trying to get my script to open Active Directory (on my computer) and then search for an employee's name. However, it seems as though the "Active Directory Users and Computers" window doesn't really respond to any thing once it's open.

; Open the RUN command
Send("#r")
Sleep(1200)
; Opens Active Directory
Send("dsa.msc /server=domainserver1.domain.com")
Send("{ENTER}")
Sleep(3000)

At this point, Active Directory Users and Computers is open and shown to connect to the specified server, but anything beyond this point does not work in the window. It works fine if I switch out AD with Notepad or Word.

If I do a Send("!a") it doesn't even indicate Alt is pressed in the window, let alone activate "Actions" menu (alt+a).

I tried appending:

WinSetState("Active Directory", "", @SW_MAXIMIZE)

...but even that won't affect the window.

Is there a better way to even do this? I'm basically trying to bring up AD and get to the Find box, and then type/paste in an employee's name that I've got copied to the clipboard.

Link to comment
Share on other sites

You could use my Active Directory UDF. Depending on the information you enter (name, samaccountname ..) and the information you want to retrieve different functions are available.

A good choice might be _AD_GetObjectsInOU.

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

Ok I'll check it out.

I did search earlier for a way to just Disable an AD account, but didn't find anything.

Ultimately, that's what I'm trying to do. But I kind of do want the AD window to open with the employee's name in the search box, so that I can go into properties manually and add details to their Description, or change their Organizational Manager, etc...

Link to comment
Share on other sites

Maybe have AutoIt launch PowerShell and type the command to disable the EmployeeName's account?

Then could Autoit wait until I close the Powershell window to resume to the program?

Edited by jgq85
Link to comment
Share on other sites

Ok I'll check it out.

I did search earlier for a way to just Disable an AD account, but didn't find anything.

Ultimately, that's what I'm trying to do. But I kind of do want the AD window to open with the employee's name in the search box, so that I can go into properties manually and add details to their Description, or change their Organizational Manager, etc...

To disable an account (where you already know the SamAccountname) the script would look like:

#include <AD.au3>
Global $sSAM = "xxx"
_AD_Open()
_AD_DisableObject($sSAM)
_AD_Close()

Some error checking after each function call is needed.

To change the description you call

_AD_ModifyAttribute($sSAM, "Description", "New Description")

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

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