LDAP implementations between different directory services providers - active-directory

I am tasked with creating a generic LDAP interface that will query groups and users. We are doing our initial testing against Active Directory, but the thought occurred to me that LDAP is just a way to query a directory database. The actual fields returned by any directory service (AD, Novell, etc) might be different.
For example, if I query a group or user through LDAP, one of the fields I get back is objectGUID, and if I use that value in subsequent requests for an individual object, that field is used to uniquely identify the LDAP record. Other fields returned by AD are cn, distinguishedName, etc.
Would any directory service that provides an LDAP interface use all the same fields? Or are the fields for each dependent upon the service being queried through LDAP?

It entirely depends on the schema that is defined in the LDAP server.
The attributes of certain objectClass could also be different from server to server.
For ex : In Novell 'groupOfUniqueNames' objectClass has 'member' attribute to store its children, where as the same 'groupOfUniqueNames' objectClass has 'uniqueMember' attribute to store its children in openDJ server.
More over some LDAP servers could use 'groupOfNames' objectClass instead of 'groupOfUniqueNames' for groups. So it entirely depends on the schema defined for that LDAP server.

Related

Ldap queries with multiple domains

I have question about LDAP queries and DC in general (in Microsoft AD):
Does a DC can contain only one domain? or sub domain can be also on it?
Does sub-domain reside in a separate DC?
if i want to get data from multiple domain/sub domains what are the ways to get all user, groups and relationship between them using LDAP queries (not using GC and without referrals) ? is the only way to do a separate LDAP query to every DC ?
Thanks
waiting for your help
Domain controllers are in charge of a single domain and holds information only about this single domain. Global Catalogs hold information about selected attributes of users and groups of all the forest (master domain and all its subdomains), so the easiest way is to run the query against a GC. Those never respond with referrals.
Every single domain controller can be configured to be a Global Catalog if needed. GC endpoint runs on port 3268 for LDAP and 3269 for LDAPS, so chances are that executing your regular LDAP(S) query against GC ports will result in what you wish. You can get the list of all GCs in the forest by querying DNS for SRV records, i.e. nslookup -type=SRV _gc._tcp.<forest name>.

ldapsearch for entire ad forest

In my AD forest i have one primary domain and three child domains.
Is there any way to query forest to search in all domains controllers to chek if user is memberof a group?
I already try ldap bind + search, but using this method i need to query each domain individual.
I also try ldap bind + search to global catalog, but global catalog don't get all the information from the childs domains, special group members.
So is there any way to search the entire forest without need to contact each domain controller?
If not possible by ldapsearch, someone can guide me the correct way?
Thanks in advance
André Bolinhas
You could try ldapsearch against the Global Catalog.
A Global Catalog server is a Domain Controller that stores Global Catalog information; its database stores rows for every object in the AD Forest instead of rows for only the objects in one AD DOMAIN.
Characteristics of Global Catalog
Global Catalogs are also Domain Controllers
Global Catalog servers stores information about all objects of all domains of the entire forest.
Global Catalog servers do Not the complete set of attributes for these objects are stored.
Global Catalog servers replicate the data with all other Global Catalogs in the forest.
Global Catalog function increases replication load on the regarding server.
Global Catalog access over LDAP is done as a normal LDAP connection over TCP port 3268 (or 3269 for LDAP over SSL).
Global Catalog requests are Read Only.
Global Catalog Domain Controller have a DNS SRV Record is created in DNS.
There are also several dsquery commands that might work.

SQL Server: LDAP query of Active Directory Group members works inconsistently

I am querying Active Directory from SQL Server via a Linked Server called LDAP.
The linked server was created thus, authenticating through a specially created service account myDomain\ServiceAccountWithNoPermissions.
exec master.dbo.sp_addlinkedserver #server = N'LDAP', #srvproduct=N'Active Directory Service Interfaces', #provider=N'ADSDSOObject', #datasrc=N'adsdatasource'
exec master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'LDAP',#useself=N'False',#locallogin=NULL,#rmtuser=N'myDomain\ServiceAccountWithNoPermissions',#rmtpassword='########'
And I'm querying the members of a specific Active Directory Group with the following:
select *
from OpenQuery (LDAP, '
select objectGUID, sAMAccountName
from ''LDAP://myServer.myDomain.com/DC=myDomain,DC=com''
where MemberOf=''CN=Some Group,OU=Folder,DC=myDomain,DC=com''
order by sAMAccountName asc
');
Here's my problem. The above system is working correctly for some Active Directory Groups and not others.
By default I think Authenticated Users is supposed to be able to query any User or Group objects in Active Directory. And as a test I verified that the effective permissions of myDomain\ServiceAccountWithNoPermissions includes "Read all properties" on Groups for which the members are both queryable and non-queryable.
What could be the difference between Groups that are queryable and non-queryable?
You didn't describe what you mean by it working incorrectly, so I can only guess. But the most obvious thing I can see is that you're querying the membership of a group by using memberOf. Depending on how your environment is setup, that may not give you all the results you hope for. I wrote about this, but here's the important part:
Groups only get added to memberOf if they have a Group Scope of:
Universal and are in the same AD forest as the user, or
Global and are on the same domain.
Groups do not get added to memberOf if they have a Group Scope of Global and are on another domain (even if in the same forest).
On top of that, memberOf will only include Domain Local groups from the same domain of the server you are retrieving results from. (if you are working in a multi-domain environment and reading from a Global Catalog, this may not be the same domain the user is from)
It will also not report the user’s primary group (usually Domain Users), if that’s important to you, nor will it include groups on external trusted domains.
The most reliable way to find all the members of a group is to read the member attribute of the group itself. But if the group is used as the primary group for any users, then you would also have to use a different way to find those.

How to find trusted domain groups using Ldap query

I have one forest like demo.com. In the forest contains two domains are first.demo.com and second.demo.com then I have several users in first.demo.com and created a group using that user. Again I created one group in second.demo.com using first.demo.com user. I want to get both groups using LDAP query.
When you run an ldap query, you query an LDAP partition, i.e. DC=first,DC=demo,DC=com. The partition DC=second,DC=demo,DC=com maybe is in the same forest, but is hosted on another domain controller and is a specific partition.
The global catalog holds information for the whole forest, but as it contains all users and groups accross the forest, some attributes are not recorded in (to minimize its size).
If you query an attribute that is not in the global catalog, my suggestion is that you should script your ldap query like this:
query the forest domain root to get the list of all domains in the forest
for each domain, run your ldap query
Found this answer here: How to find trusted domain groups using Ldap query

Import ActiveDirectory LDIF into OpenDJ/OpenDS?

I need to test a LDAP synchronization service.
For that reason, I've installed OpenDJ (formerly OpenDS) LDAP server on my developer machine (ApacheDS requires admin privileges for starting/stopping a service - I don't have them & I don't get them).
OpenDS allows me to populate the LDAP with 2000 sample entries.
Unfortunately, they aren't very AD conformant:
I need an ActiveDirectory properties structure:
I used an LDIF-generator from here to generate the ActiveDirectory entries.
Then I tried importing them with Apache Directory Studio:
But on importing, I get this error: [LDAP: error code 65 - Entry
cn=Trang Eastus,ou=Product Testing,dc=example,dc=com violates the
Directory Server schema configuration because it includes attribute
sAMAccountName which is not allowed by any of the objectclasses
defined in that entry]
How can I import a ActiveDirectory schema with Apache Directory Studio ?
Or more generically asked, how can I get these entries in there, ASAP ?
Active Directory attribute types are not standard, so they do not come bundled in OpenDJ.
So you first need to modify OpenDJ's schema to allow adding Active Directory attributes.
I suspect you would have the same kind of problems with other LDAP servers like OpenLDAP.
I don't think Active Directory exposes its schema in an LDAP compliant way. What most users are doing when synchronizing data between AD and other LDAP servers such as OpenDJ is mapping AD attributes and objectclasses to LDAP attributes and objectclasses.
This said, you should be able to reconstruct a "user" LDAP objectclass based on Microsoft documentation of their schema. The best source I found is this table : http://www.kouti.com/tables/userattributes.htm. I don't think anyone has been down that route and efforts.
Beware, in LDAP worlds, the hierarchy of person objectclasses is person, organizationalPerson, inetOrgPerson. In MS AD world, the objectclass user is in the middle : person, organizationalPerson, user, inetOrgPerson.

Resources