Sign in to follow this  
Followers 0
alan lim

Output to _array

7 posts in this topic

How to make the following line to output to an array instead to a text file? The reason is if I output to a file, and at the end I have to delete it. Is quite troublesome. Thank you

runwait(@ComSpec & " /c" & "dsquery user "& '"ou=HR,dc=xxxx,dc=com"' & " -name" &" alan*")

Alan Lim

Share this post


Link to post
Share on other sites



To query the Active Directory you could use the ADFunctions UDF. This would solve this (and probably future) problems.


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

I did try on ADFunction but it does not show description on user object. I like to query AD user name with desciption. Is that possible?

Thank you

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes, it's possible. Something like this:

#include <adfunctions.au3>

Global $asUsers
_ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"name,description")
_ArrayDisplay($asUsers)

Each function in adfunctions.au3 has a description of the required parameters. The term "(&(objectCategory=user)(name=alan*))" is an ordinary LDAP query string. Documentation on how to build such strings can be found on the internet.

Edited by water

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

Thank you for your replied.

I have copied your script and run it. The description still show nothing.

I have even remove the name and left the desciption, _ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"description"). The array don't show anything. This is the problem I have facing.

Share this post


Link to post
Share on other sites

Are you sure that the description field is filled in AD? Could you download the Active Directory Explorer from M$ (previous Sysinternals) and run it (no installation required, just run the exe) to check if there is a 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

Yes, it's possible. Something like this:

#include <adfunctions.au3>

Global $asUsers
_ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"name,description")
_ArrayDisplay($asUsers)

Each function in adfunctions.au3 has a description of the required parameters. The term "(&(objectCategory=user)(name=alan*))" is an ordinary LDAP query string. Documentation on how to build such strings can be found on the internet.

I haven't gotten terribly far in my LDAP query studies, is there a way we can pull a schema attribute into that array? something like ,2,"name,lastLogin". The end goal is to pull this value and then run it against a last login calculator so I can disable inactive computer accounts.

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