[Last Call] Learn how to a build a cloud-first strategyRegister Now


LDAP issues

Posted on 2009-04-17
Medium Priority
Last Modified: 2013-12-24
Im using some simple VB LDAP code to check list of users in excel, to display their name, location and job etc....

We have 2 DC's where i work and i only seem to be able to LDAP to one of them.
the other DC always returns a null result.

This is odd, as i do have access to view both of the DC's via Active Role Server (the online GUI).

Any reason that this might happen? is it possible to secure a DC against people doing an LDAP query via an AD group for example?
Question by:jamiepryer
  • 3
  • 3
LVL 71

Expert Comment

by:Chris Dent
ID: 24166075

Can you show us the code?

> is it possible to secure a DC against people doing an LDAP query via an AD group for example?

By default all Authenticated Users have read access to (most of) Active Directory. You can revoke that right, but it must be done with care.


Author Comment

ID: 24166118
thanks for the info chris
very interesting to know about the LDAP and it being hard to revoke....

The 2 DC's i have are:

Global.FakeCompany.Com - can query fine....
strdomain = "DC=Global,DC=Lloydstsb,DC=Com"

OUTLET.AD.FakeCompany.COM - wont let me query
strdomain = "DC=OUTLET,DC=AD,DC=FakeCompany,DC=COM"
Dim objConnection As New ADODB.Connection
Dim objCommand As New ADODB.Command
Dim objRecordset As ADODB.Recordset
'Set up the criteris for the LDAP searches
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
 strDomain = "DC=OUTLET,DC=AD,DC=FakeCompany,DC=COM"
    objCommand.CommandText = _
        "SELECT description, userAccountControl, displayname, mail, distinguishedName, physicaldeliveryofficename FROM 'LDAP://" & strDomain & "' WHERE objectCategory='user' " & _
        "AND Name='" & xxUserIDxx & "'"
Set objRecordset = objCommand.Execute
If objRecordset.RecordCount > 0 Then
        ActiveSheet.Cells(1, 2) = description
        ActiveSheet.Cells(1, 3) = userAccountControl
        ActiveSheet.Cells(1, 4) = displayname
End if

Open in new window

LVL 71

Expert Comment

by:Chris Dent
ID: 24166164

This part:


Is that the actual AD domain name? Because all you're doing is connecting to the "Domain Component" for a specific domain here.

For example, an AD Domain called ad.FakeCompany.com would be referred to as "DC=ad,DC=fakecompany,DC=com" on all DCs for that domain.

To connect to a different DC you would make it:


When combined with your CommandText that gives you this connection string:


Search Base could also extend into the AD structure, e.g.


Which can also be prefixed with the server name or IP to force a connection via a specific DC.

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Author Comment

ID: 24166253
sorry for being stupid but my AD/LDAP knowledge is not *that* great

how do i establish what the correct name should be for the "OUTLET.AD.FakeCompany.COM " AD domain?

In ARS, when i search on a user that has an ID in the domain "OUTLET.AD.FakeCompany.COM ", their full DN is:
CN=xxUserIDxx,OU=Outlet Users,DC=OUTLET,DC=AD,DC=FakeCompany,DC=com

my ID on the other domain (which i can do LDAP on), is:
CN=xxMexx,OU=Head Office Users,DC=Global,DC=Lloydstsb,DC=Com

apologies if im totally missing your point...
LVL 71

Accepted Solution

Chris Dent earned 1000 total points
ID: 24166469

I think the problem is coming because ADSI is being a bit too helpful.

You see when you do this:

 strdomain = "DC=Global,DC=Domain,DC=Com"

It creates this connection string:


You're telling it "what" to connect to, but not "where". Because you're (presumably) running this from a client belonging to the Global domain, or even the server itself it assumes you want a resource on a Domain Controller nearby. In essence it assumes this:


Where "global.domain.com" will resolve using a tool like NsLookup to an IP address of a server capable of obtaining the information.

If ADSI didn't make that assumption you would have to tell it where to connect to as well as what.

I think that's where we're getting hung up. If you were to run the script from the server or a client within the Outlet domain it would quite happily go on with the query. But to run it remotely you must specify where to avoid it's assumptions.

That makes strDomain into this:

  strDomain = "outlet.ad.fakecompany.com/DC=OUTLET,DC=AD,DC=FakeCompany,DC=COM"

And the resulting connection string into this:


If you don't specify that value it makes an assumption and tries:


Which won't work because global.domain.com cannot give you answers about outlet.ad.fakecompany.com[1].

Does that make any sense?


[1] There's a caveat there. If both are within the same forest, then it can if you instruct it to connect to the Global Catalog (GC://global.domain.com/DC=outlet,DC=ad,DC=fakecompany,DC=com). However, the Global Catalog is read-only and contains a sub-set of attributes so may not necessarily be useful here.

Author Comment

ID: 24167898
Thanks for you help, altho i cant get the 2nd bit to work, using this:
"  strDomain = "outlet.ad.fakecompany.com/DC=OUTLET,DC=AD,DC=FakeCompany,DC=COM"
i did however manage to ping the domain and then use the IP address i got back as StrDomain, this now works.

Thanks very much for your help and information, ive learnt something today :)

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question