vbscript: script assistance

Hello,

I currently have a vb script that searches for a computer object in the current forest. I want to search for a computer object in a remote forest which is 2-way trust and I have full access. I want to return an attribute called attrib1. Could you please help.

I am logged onto Forest A, I need to search for a computer object in all of the domains in Forest B and return the attribute called attrib1.

Thanks.
Parity123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nadav SolomonCommented:
you can use powershell cmdlet (first import-module activedirectory)
get-adcomputer -identity computername -server dcFromDomanB -properties attrib1

Open in new window

Another option is to use ADSI
#mind the $ sign after the computer name
$searcher = [ADSISearcher]"(&(objectClass=Computer)(sAMAccountName=computername$))"
$domain = New-Object System.DirectoryServices.DirectoryEntry("dc=domainb,dc=com")
$searcher.SearchRoot = $domain
$computer = [ADSI]$(($searcher.FindOne()).path))
$computer.attrib1

Open in new window

If you want to stick with vbscript post your script.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Parity123Author Commented:
How do I search the entire forest (with a few domains) for a computer object and retrieve attrib1
0
Parity123Author Commented:
This is the vbscript I have:
This works for the current forest, but not for the remote forest. I want to connect to a remote forest and extract data.

Dim Info1
      strServer = "computer1"
      Set objBase = GetObject("LDAP://rootDSE")
      objbase   = "<LDAP://" & oBase.Get("defaultNamingContext") & ">"
      filter = "(&(objectClass=Computer)(objectCategory=Computer)(primaryGroupID=516)(name=" & strserver & "))"
      attr  = "PasswordLastSet"
      scope  = "subtree"

      Set conn = CreateObject("ADODB.Connection")
      conn.Provider = "ADsDSOObject"
      conn.Open "Active Directory Provider"

      Set cmd = CreateObject("ADODB.Command")
      Set cmd.ActiveConnection = conn
      cmd.CommandText = objbase & ";" & filter & ";" & attr & ";" & scope
      cmd.Properties("Chase referrals") = &h60

      Set rs = cmd.Execute
            
      Do While Not rs.EOF
            info1 = rs.Fields("PasswordLastSet")
            rs.MoveNext
      Loop
      Msgbox info1
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

Nadav SolomonCommented:
your objbase should point to = "<LDAP://frestBDomainController/dc=domainB,dc=com>"
BUT you will probably be able to only search in that domain not the hole forest for 2 reasons.
1) you need to search in global catalog (put GC: instead of LDAP:) the thing is that the attribute you are searching for is probably not indexed into the global catalog.
2) im not sure your trust is transitive (depends on what you choose when you created it).

anyway try it out, maybe it will work.
0
Parity123Author Commented:
This attribute is not in GC. The  challenge I have is to search the entire forest for object
0
Nadav SolomonCommented:
Enumerate domains in forest b and search them one by one.
0
Nadav SolomonCommented:
Glad I could help, thanks for the feedback.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.