alan lim Posted November 11, 2009 Share Posted November 11, 2009 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 Link to comment Share on other sites More sharing options...
water Posted November 11, 2009 Share Posted November 11, 2009 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
alan lim Posted November 12, 2009 Author Share Posted November 12, 2009 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 Link to comment Share on other sites More sharing options...
water Posted November 12, 2009 Share Posted November 12, 2009 (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 November 12, 2009 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
alan lim Posted November 13, 2009 Author Share Posted November 13, 2009 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. Link to comment Share on other sites More sharing options...
water Posted November 13, 2009 Share Posted November 13, 2009 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
KyngLewie Posted December 2, 2009 Share Posted December 2, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now