Sign in to follow this  
Followers 0
jgq85

Opening Active Directory

6 posts in this topic

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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0