Jump to content
Sign in to follow this  

Active Directory query, array and object problems

Recommended Posts


Hi, i'am trying to get all mails from each user of my AD.

i ve tried this:

#include <adfunctions.au3>
#include <array.au3>
Const $ADS_NAME_TYPE_NT4 = 3
Const $ADS_NAME_TYPE_1779 = 1
    $objTrans = ObjCreate("NameTranslate")
    $objTrans.Init ($ADS_NAME_INITTYPE_GC, "")
    $objTrans.Set ($ADS_NAME_TYPE_1779, @LogonDomain)
Dim $test[999999]
;Dim $mail[5]
Dim $objectarray
$ou = "ou=xxx,dc=xxx,dc=xxx"
_ADGetObjectsInOU_moded($objectarray, $ou, "(&(objectCategory=person)(objectClass=user))", 2,"sAMAccountName","sAMAccountName")

; _ADGetObjectsInOU_moded

Func _ADGetObjectsInOU_moded(ByRef $ObjectArray, $ou, $filter = "(name=*)", $searchscope = 2, $datatoretrieve = "sAMAccountName", $sortby = "sAMAccountName")
    Local $objRecordSet
    $objCommand = ObjCreate("ADODB.Command")
    $objCommand.ActiveConnection = $objConnection
    $objCommand.Properties ("Page Size") = 256
    $objCommand.Properties ("Searchscope") = $searchscope
    $objCommand.Properties ("TimeOut") = 20
    $strCmdText = "<LDAP://" & $strHostServer & "/" & $ou & ">;" & $filter & ";" & $datatoretrieve & ";subtree"
    $objCommand.CommandText = $strCmdText
    $objRecordSet = $objCommand.Execute
    $recordcount = $objRecordSet.RecordCount
    If $recordcount = 0 Then
        $objCommand = 0
        $objRecordSet = 0
        Return 0
        Dim $ObjectArray[$recordcount + 1]
        $ObjectArray[0] = UBound($ObjectArray) - 1
        If $ObjectArray[0] = 0 Then
            $ObjectArray = 0
            Return 0
            $count = 1
                $ObjectArray[$count] = $objRecordSet.Fields ($datatoretrieve).Value
                        $objTrans.Set ($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $ObjectArray[$count])
                    $strUserDN = $objTrans.Get ($ADS_NAME_TYPE_1779)
                    $UserObj = ObjGet("LDAP://" & $strUserDN)
                    _ArrayDisplay($mail); show email in an array
                    MsgBox(0,"",$mail[1]); show an error
                    For $i =0 to UBound($mail-1)
                        $test[0][$k]=$ObjectArray[$count] ;username
                    ;_ArrayDisplay($UserObj.PROXYAddressES); works too

                $count += 1
            Until $objRecordSet.EOF
    $objCommand = 0
    $objRecordSet = 0
    Return 1
EndFunc   ;==>_ADGetObjectsInOU
but it seems too much complicated to get an array:

user1 mail1

user1 mail2

user1 mail3

user2 mail1


mail are stored in userADobj.proxyadresses

Thanks for the help

Edited by Kilhian

Share this post

Link to post
Share on other sites

Last up...

76 read.. nobody could help me to resolve this array/object problem...

So bad

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.