Jump to content

Query a computer account exists in AD


Recommended Posts

I found this vbscript snippet which might give some hints.

CODE
Function isComputerAccountExists(host)

Dim conn, cmd , rs

Set conn = CreateObject("ADODB.Connection")

Set cmd = CreateObject("ADODB.Command")

conn.provider = "adsdsoobject"

conn.open "active directory provider"

cmd.activeconnection = conn

cmd.commandtext = ";(&(objectcategory=computer)(objectclass=computer)(cn=" & host & "));cn;subtree"

Set rs = cmd.Execute

If rs.recordcount = 0 Then

isComputerAccountExists = False

Else

isComputerAccountExists = True

End If

End Function

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...