Sign in to follow this  
Followers 0
darkleton

_AD_GetObjectsInOU error

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

thank you (again!) :(

I'm sure it displaying computers too is something i've missed out, but thank you :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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