Do not use on any
shared computer
August 29, 2008 08:09pm pdt
 
[x]
Attachment Details

query computer description in Active Directory

Tags: computer, description, directory, active, query
Experts -

I'm having all sorts of troubles returning the Description field for Computers in Active directory. Below is the code I'm using. I'm getting all other attributes, no problem. Any obvious problems with this sub?

Private Sub Computers_Click()
 On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2

    Dim conn4 As ADODB.Connection
    Dim rs4 As ADODB.Recordset
   
    Set conn4 = CurrentProject.Connection
    Set rs4 = New ADODB.Recordset
    rs4.Open "tbl_ad_computers", conn4, adOpenDynamic, adLockOptimistic

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT name, description, dnshostname, machinerole, operatingsystem, operatingsystemversion, operatingsystemservicepack FROM 'LDAP://OU=Computers,OU=MyCity,OU=Regions,dc=mydomain,dc=prv' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    'Wscript.Echo objRecordSet.Fields("Name").Value
    rs4.AddNew
    rs4.Fields("cn").Value = objRecordSet.Fields("name").Value
    rs4.Fields("description").Value = objRecordSet.Fields("description").Value
    rs4.Fields("dnshostname").Value = objRecordSet.Fields("dnshostname").Value
    rs4.Fields("machinerole").Value = objRecordSet.Fields("machinerole").Value
    rs4.Fields("operatingsystem").Value = objRecordSet.Fields("operatingsystem").Value
    rs4.Fields("operatingsystemversion").Value = objRecordSet.Fields("operatingsystemversion").Value
    rs4.Fields("operatingsystemservicepack").Value = objRecordSet.Fields("operatingsystemservicepack").Value
    rs4.Update
    objRecordSet.MoveNext
Loop

End Sub

Thanks,
crafuse
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: OS
Question Asked By: crafuse
Solution Provided By: Netman66
Participating Experts: 1
Solution Grade: A
Views: 77
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by Netman66

Rank: Wizard

Expert Comment by Netman66:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by crafuse
Author Comment by crafuse:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Netman66

Rank: Wizard

Expert Comment by Netman66:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by crafuse
Author Comment by crafuse:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by Netman66

Rank: Wizard

Accepted Solution by Netman66:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by crafuse
Author Comment by crafuse:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Open Discussion
Open Discussion
 
Comment by Netman66
Keep up the coding skills - they're valuable.

Glad to at least chat!  LOL...

Thanks again,
NM
 
 
20080723-EE-VQP-34 / EE_QW_2_20070628