This one looks if the SAMAccountname "PeterW" is in use in the "Users" OU in the domain "domain".
If it doesnt find it it will tell you that and if it finds it then you'll see the dn path and so on.
//Peter
Set objConnection = CreateObject("ADODB.Connection"

objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command"

objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<GC://ou=Users,dc=domain,dc=com>;" & _
"(&(objectCategory=person)(objectClass=user)" & _
"(sAMAccountName=PeterW));" & _
"sAMAccountName, distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
Wscript.Echo "The sAMAccountName is not in use."
Else
While Not objRecordset.EOF
Wscript.Echo "sAMAccountName = " & _
objRecordset.Fields("sAMAccountName"

Wscript.Echo "distinguishedName = " & _
objRecordset.Fields("distinguishedName"

objRecordset.MoveNext
Wend
End If
objConnection.Close