943,778 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2136
  • VB.NET RSS
Sep 4th, 2008
0

Display List of Computers in a Specific OU in VBA

Expand Post »
I have two OUs OU=Student and OU=Teachers and my root OU is

LDAP://dc=test,dc=labs,dc=edu

in the Student OU i have three computers named Std1,Std2,Std3 and three computers in Teachers OU named Tea1,Tea2,Tea3

I am writing a VBA script in Excel in which i want to display my Computers in that OU in a excel spreadsheets.

Computer Name Description OU

Std1 Student Computers Student

Std2 Student Computers Student

...................List goes on.......list of all computers in Student OU and Teachers OU

This is my script but its not working can anyone help me?
vbnet Syntax (Toggle Plain Text)
  1. Sub ListDomains()
  2.  
  3. Dim objNameSpace
  4. Dim Domain
  5. Dim ou
  6. Dim pcs
  7. Set objNameSpace = GetObject("LDAP://dc=test,dc=labs,dc=edu")
  8. For Each objDomain In objNameSpace
  9. ou = objDomain.Name
  10. objDomain.Filter = Array("Computer")
  11.  
  12. For Each objComputer In objDomain
  13. pcs = objComputer.Name
  14. Dim i
  15. For i = 0 To pcs.Count - 1
  16. Cells(i, 1) = pcs
  17. Next
  18. Next
  19. Next
  20.  
  21. End Sub
Last edited by cscgal; Sep 4th, 2008 at 5:42 pm. Reason: Added code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
buffdaemon_live is offline Offline
3 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: how to compress and send a file for a Infrared modem?
Next Thread in VB.NET Forum Timeline: creating macros using vb





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC