Jump to content

_AD_GetObjectsInOU error


Recommended Posts

This should just display all user accounts on the whole AD tree shouldn't it?

_AD_Open()
$arUsers = _AD_GetObjectsInOU("", "(&(objectclass=user)(name=*))", 2, "sAMAccountName", "sAMAccountName")
_ArrayDisplay($arUsers)
_AD_Close()

I have tried changing objectclass to other things, changing the last two to "cn" or "displayname" but every time it just returns a 1501 line array, with the first line stating "1501" and the rest blank. Other commands like _AD_GetAllOUs works fine and will display all the OUs in an array nicely.

Am I doing something stupidly wrong?

Edited by darkleton
Link to comment
Share on other sites

Hi,

this code works, although not as expected, because i get also the computeraccounts:

#include <ad.au3>
#include <array.au3>
_AD_Open()
$arUsers = _AD_GetObjectsInOU("", "(&(objectclass=user)(name=*))", 2) ;, "sAMAccountName", "sAMAccountName")
_ArrayDisplay($arUsers)
_AD_Close()

;-))

Stefan

@Edit: My glasbowl shows me, that you are using AD.au3 Version 0.37. It works for me, because i'm still using 0.35.

There is a bug (just performed a search over forum).

Please change in AD.au3 as follow:

1.

In the new version AD 0.37 the Func _AD_GetObjectsInOU returns an empty array because of $aAD_DataToRetrieve.

Original:

Line 1133:

$aAD_Objects[$iCount2] = $oAD_RecordSet.Fields($aAD_DataToRetrieve).Value

Fixed (like previous versions):

Line 1133:

$aAD_Objects[$iCount2] = $oAD_RecordSet.Fields($sAD_DataToRetrieve).Value -> Hardly to see: The change is from $aAD to $sAD

Edited by 99ojo
Link to comment
Share on other sites

Back from vacation so I now start to reply again :(

To get a list of all users from all OUs you have to add the objectcategory. So please try something like:

$aObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName")

I've extended the examples in the _AD_GetObjectsInOU.au3 so please have a look there as well.

I will investigate the error and hope to release a new version quite soon.

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

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