Kilhian Posted March 18, 2008 Share Posted March 18, 2008 (edited) Hi, i'am trying to get all mails from each user of my AD. i ve tried this: expandcollapse popup#include <adfunctions.au3> #include <array.au3> Const $ADS_NAME_INITTYPE_GC = 3 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") _ArrayDisplay($objectarray) ; _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 EndIf Dim $ObjectArray[$recordcount + 1] $ObjectArray[0] = UBound($ObjectArray) - 1 If $ObjectArray[0] = 0 Then $ObjectArray = 0 Return 0 Else $count = 1 $k=0 $objRecordSet.MoveFirst Do $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) $mail=$UserObj.PROXYAddressES _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 $test[1][$k]=$mail[$i];email $k+=1 Next ;_ArrayDisplay($UserObj.PROXYAddressES); works too $objRecordSet.MoveNext $count += 1 Until $objRecordSet.EOF EndIf $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 March 19, 2008 by Kilhian Link to comment Share on other sites More sharing options...
Kilhian Posted March 18, 2008 Author Share Posted March 18, 2008 No hints? Link to comment Share on other sites More sharing options...
Kilhian Posted March 19, 2008 Author Share Posted March 19, 2008 No idea where i am wrong Link to comment Share on other sites More sharing options...
Kilhian Posted March 20, 2008 Author Share Posted March 20, 2008 Last up... 76 read.. nobody could help me to resolve this array/object problem... So bad 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