views:

117

answers:

1

I wrote this code in ColdFusion to read data from Exchange and am wondering if anyone can help me to code this using Visual Basic Script:

<cfldap
  server="insert_my_server_name_here"
  username="zzz\zzzzzz"
  password="xxxx"
  port = "123"
  action = "query"
  name = "data"
  attributes = "company"
  filter = "(&(objectclass=group))"
  returnAsBinary = "objectSID"
>

I got this far, but it returns a table not found error:

Dim UserID
UserID = "my_user_ID"

Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"

Dim Base, Filter, Attr, Level, Server
Server = "insert_my_server_name_here"

Base = "<LDAP://" & Server & "/DC=dot,DC=com>;"
Filter = "(&(objectClass=user)(objectCategory=person)(samAccountName=" & UserID & "));" 
Attr = "distinguishedName;"
Level = "SubTree"

Set RecordSet = objConn.Execute(Base & Filter & Attr & Level)

RecordSet.MoveFirst
While Not RecordSet.EOF
  Wscript.echo RecordSet.Fields(0).Value
  RecordSet.MoveNext
Wend
+1  A: 

The code you've posted is fine.

I think you must have an incorrect reference to your domain in the LDAP query string. You are using the variable 'Server' to provide the name of a domain controller which is fine (but usually unnecessary), but are you changing 'DC=dot,DC=com' to reflect the name of your domain? EG if your domain is My.Domain it should be 'DC=My,DC=Domain'

FitzRoy