0

When I ping 140West-dc it returns:

Pinging 140West-dc.bvncap.local

And my LDAP Query is as follows:

LDAP://dc=bvncap,dc=local

Is there anyway to pass "140West-dc.bvncap.local" to LDAP query instead of just "bvncap.local"

Note: 140West is my office location.

EDIT:

I pass the common name to the query like this:

LDAP://cn=140West-dc,dc=bvncap,dc=local

But get an error:

Run-time error : There is no such object on the server

Here is the command text:

SELECT AdsPath FROM 'LDAP://cn=140West-dc,dc=bvncap,dc=local' WHERE objectCategory='user' And sAMAccountName = 'hjose'

Get this error when i execute:

set rs = cmd.Execute
user793468
  • 115
  • 5

2 Answers2

1

I read this first.

You could try this connection string:

LDAP://140West-dc.bvncap.local/dc=bvncap,dc=local

woohooyeah
  • 26
  • 1
1

LDAP connection strings need the following syntax:

LDAP://[<server name>/]<baseDN>

The server name is optional, but if needed, can be an IP address or any resolvable DNS entry (i.e., 140west-dc or 140west-dc.bvncap.local). If not specified, it'll connect to a DC that's associated with the IP range in AD Sites & Services.

The baseDN is where in the directory you connect. You can connect to the root of your domain (dc=bvncap,dc=local), or a subdomain of your parent domain (dc=subdomain,dc=bvncap,dc=local), or an OU somewhere underneath that (ou=Level2,ou=Level1,dc=bvncap,dc=local). This affects where your search begins.

There's some good info here: LDAP ADsPath

Also, your WHERE clause should have "objectClass=user" or "objectCategory=person". However, that attribute isn't needed, as sAMAccountName is unique within the directory, so it'll only return one object either way.

DarkMoon
  • 1,039
  • 13
  • 29