This simple code queries one of our DDNS domains using LDAP and
attempts to get the IP address for a printer. It finds the printer
with no problem and I can dislpay the printer using the "name" field
(code is omitted) but what I also want is the IP address. It is stored
in the "dnsRecord" field and is the last 4 sets of numbers. If I could
just get those numbers I could parse/convert/ change the heck of them
but I can't get anything from the dnsRecord field. all I get are two
boxes which I can't type since they lijke some obscure ASCII but they
are certainoy not numbers. Maybe I am reading an object from LDAP
which needs further work? I dont know. however if I use
"adsiedit.msc" I can see the numbers in the dnsRecord field I can't
can't query them or display them with my code... heelppppp
here's the code:
'------- Declare variables --------
Set cnvt = CreateObject("ADs.ArrayConvert")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
'------- Run LDAP query -------
objCommand.CommandText = _
"<LDAP://DC=usfca.printer,CN=MicrosoftDNS,CN=System,DC=ds,DC=usfca,DC=edu>;(&(DC="
& "hr" & "545" & "*))" & ";dnsRecord;subtree"
Set objRecordSet = objCommand.Execute
'------- Parse the resultant query and display the results -------
While Not objRecordSet.EOF
Wscript.Echo join(objRecordSet.Fields("dnsRecord"))
objRecordSet.MoveNext
Wend
objConnection.Close