You should be able to get this by querying a GC.

vbscript below will query a GC in bbb.com for users phone numbers in ccc.com
(watchout for textwrap)....

--------------------------------
const useGlobalCatalogue = "mygcin_bbb.bbb.com"
const SearchBase = "dc=ccc,DC=com"

Dim objConnection, objCommand, objRecordset

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 50

objCommand.CommandText = "<GC://" & useGlobalCatalogue & "/" & SearchBase &
">" & _
        ";(&(objectCategory=person)(objectClass=user))" & _
        ";cn,telephoneNumber" & _
        ";Subtree"

Set objRecordset = objCommand.Execute

if objRecordset.RecordCount = 0 then 
        wscript.echo "0 matching records found, exit"
        wscript.quit(0)
end if

Wscript.echo "found " & objRecordset.RecordCount & " records"

objRecordset.MoveFirst
do
        wscript.echo objRecordset.Fields("cn") & " phoneNumber... (" &
objRecordset.Fields("telephoneNumber") & ")"
        objRecordset.MoveNext
loop until objRecordset.eof or objRecordset.bof

Set objRecordset = nothing
Set objCommand = nothing
Set objConnection = nothing 
--------------------------------

Hope that helps.

Cheers, 
Matty

-----Original Message-----
From: Jason Benway [mailto:[EMAIL PROTECTED] 
Sent: 02 August 2004 15:59
To: '[EMAIL PROTECTED]'
Subject: [ActiveDir] Active directory scripting question

Ok, here's our AD forest setup. We have one forest.

Aaa.com is the root of the forest.
We have about 5 other domains in the same forest.
Bbb.com
Ccc.com
Ddd.com
etc

I work for bbb.com we are trying to create an AD phone list for the entire
forest. Shouldn't we be able to query a DC in bbb.com and get phone info for
any user in the forest?

Thanks,jb
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to