Discussion:
Retrive operatingSystem from Active Directory
(too old to reply)
Jesper Ravn
2009-10-29 13:53:45 UTC
Permalink
Hello

How can i retrive operatingSystem from a specific computer/server.
Please see my code below.

Dim StrComputer as string
StrComputer = "SQLserver01"

adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
& "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
& "and Name = " & StrComputer & ""

adoRecordset = adoCommand.Execute

Dim strOperatingSystem As String
strOperatingSystem = adoRecordset.Fields("operatingSystem").Value

It fails when running the execute command.
Hopefully you can me in the right direction.

Thanks;

/Jesper
Jesper Ravn
2009-10-29 15:28:35 UTC
Permalink
Post by Jesper Ravn
Hello
How can i retrive operatingSystem from a specific computer/server.
Please see my code below.
Dim StrComputer as string
StrComputer = "SQLserver01"
adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
& "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
& "and Name = " & StrComputer & ""
adoRecordset = adoCommand.Execute
Dim strOperatingSystem As String
strOperatingSystem = adoRecordset.Fields("operatingSystem").Value
It fails when running the execute command.
Hopefully you can me in the right direction.
Ok, I found the solution. It was a syntax error

adoCommand.CommandText = "Select Name, operatingSystem From " & _
LDAP://DC=Domain,DC=Com' Where objectClass='computer'" & _
" and Name = '" & StrComputer & "'"

/Jesper
Pegasus [MVP]
2009-10-29 17:21:49 UTC
Permalink
Post by Jesper Ravn
Post by Jesper Ravn
Hello
How can i retrive operatingSystem from a specific computer/server.
Please see my code below.
Dim StrComputer as string
StrComputer = "SQLserver01"
adoCommand.CommandText = "SELECT Name, operatingSystem FROM " _
& "'LDAP://DC=DOMAIN,DC=COM' WHERE objectClass='computer' " _
& "and Name = " & StrComputer & ""
adoRecordset = adoCommand.Execute
Dim strOperatingSystem As String
strOperatingSystem = adoRecordset.Fields("operatingSystem").Value
It fails when running the execute command.
Hopefully you can me in the right direction.
Ok, I found the solution. It was a syntax error
adoCommand.CommandText = "Select Name, operatingSystem From " & _
LDAP://DC=Domain,DC=Com' Where objectClass='computer'" & _
" and Name = '" & StrComputer & "'"
/Jesper
Your updated code still has syntax problems - you've got unmatched
single/double quotes.

Loading...