Min sub ser sådanne ud:
Sub find_bruger()
' Create the connection and command object.
Set oConnection1 = CreateObject("ADODB.Connection")
Set oCommand1 = CreateObject("ADODB.Command")
' Open the connection.
oConnection1.Provider = "ADsDSOObject" ' This is the ADSI OLE-DB provider name
oConnection1.Open "Active Directory Provider"
' Create a command object for this connection.
Set oCommand1.ActiveConnection = oConnection1
' Compose a search string.
oCommand1.CommandText = "select name, telephoneNumber, mail, title, facsimileTelephoneNumber, mobile, distinguishedName " & _
"from '
LDAP://servernavn'" & _
"WHERE objectCategory='Person'" & _
"AND objectClass='user'" & _
"AND department=100" & _
"OR department=210" & _
"OR department=220" & _
"OR department=230" & _
"OR department=300" & _
"OR department=310" & _
"OR department=400" & _
"OR department=410" & _
"OR department=700"
' Execute the query.
Set rs = oCommand1.Execute
'--------------------------------------
' Navigate the record set
'--------------------------------------
While Not rs.EOF
startBoks.ComboBox1.AddItem rs.Fields("name")
'Debug.Print rs.Fields("name") & ", " & rs.Fields("telephoneNumber") & ", " & rs.Fields("mail") & ", " & rs.Fields("title") & ", " & rs.Fields("facsimileTelephoneNumber") & ", " & rs.Fields("mobile") & ", ---- " & rs.Fields("distinguishedName")
rs.MoveNext
Wend
End Sub