LDAP: Filter users belonging to a group across multiple OU's - ldap

I've the following structure in AD
DC=comp,DC=com
OU=city1
OU=group
OU=users
user1
user2
OU=city2
OU=group
OU=users
user3
user4
I am trying to filter and retrieve user 1-4 in a single query. I've tried the filter
(dn=OU=users,ou=*,DC=comp,DC=com) but it returned empty. What's the best way to filter in this condition?

Unfortunately, Microsoft Active Directory does not support extensible match filter for this condition.
If these are the only users, setting a base at "DC=comp,DC=com" will return the users.

Related

LDAP query to get the list of users which are matching the group pattern

I am trying to query the groups from Ldap starting with groupname-* and all users part of these groups.
Group filter condition is: (CN=groupname-*).
User filter condition is: (memberof=cn=groupname*,OU=Application,OU=Groupings,DC=xx,DC=com))
This is returning all groups matching the pattern. However I'm not able to get the users details.Works only when I specify the complete group name in user filter. Is there any way to get all users matching the group pattern.
It appears you are querying AD. When searching for memberOf, only complete values are supported, not wildcards.
So your best bet is to query the groups and read their member attribute in order to get a list of user DNs.

LDAP Query, two groups one with user and the other with user groups

im new to LDAP and I would like query a set of data in LDAP
Ou A - has user group but no users
Ou B - has users but not user group
The users in B are linked to A via different group respectively, how can i link and query them out?
ive tried using membersof but dont seem to be working, do i need to put in the cn of each group?
Edit: i found a simliar post but it was in docker, i would like to translate it into jira's ldap
https://i.stack.imgur.com/puX2V.png
from how to get groups of a user in ldap

LDAP authentication filter to validate which employee is belong to which group

I am doing LDAP authentication for the user.
Steps are -
1. when users enter his username on the login screen.
2. The request goes to the LDAP server and will try to validate the user against its corresponding group
filter :="(|(employeeNumber=deeps)(memberOf=CN=DEV_Admin,OU=LDAP,DC=TEMP,DC=com))"
This filter works fine and giving me the employee details of the relevant group.
Now the requirement changes -
When the user enters his employeeNumber =deeps
we have to validate him against different groups for example
(memberOf=CN=DEV_Admin,OU=LDAP,DC=TEMP,DC=com)
(memberOf=CN=DEV_View,OU=LDAP,DC=TEMP,DC=com)
(memberOf=CN=DEV_Partial,OU=LDAP,DC=TEMP,DC=com)
Can anyone help me with writing a proper filter which checks against all those groups and gives me the user in one filter rather than writing three LDAP requests?
The filter seems incorrect to me as it tests if the employeeNumber is deeps OR if entries are in the Dev_Admin group. It seems to me that you want an AND, not an OR.
To check the 3 groups, it would be the following filter:
(&(employeeNumber=deeps)(|(memberOf=CN=DEV_Admin,OU=LDAP,DC=TEMP,DC=com)(memberOf=CN=DEV_View,OU=LDAP,DC=TEMP,DC=com)(memberOf=CN=DEV_Partial,OU=LDAP,DC=TEMP,DC=com)))

LDAP group has 'member's but the members dont have the 'memberof' attribute

I am new to LDAP (AD) and I wonder how can I retrieve all users of a group if the users itself doesn't have the "memberof" attribute (which should link to the group I think)?
Following LDAP Structure
- Users
- UserA (memberof=Group1)
- UserB (memberof=Group1,memberof=Group2)
- UserN ...
- Groups
- Group1 (member=UserA,member=UserB)
- Group2 (member=UserB)
- GroupX ...
- AppGroups
- App1 (member=UserA,member=UserB)
- AppX ...
So how can I query only the users which are members of App1 group from AppGroups if the users don't have the attributes memberof for this group?
I am trying to achive this with Alfresco. Querying the groups is no problem but I can't find a way to also sync the users (and only the users of the group App1)?
Thank you in advance!
You can either form a query that asks the server to retrieve all users whose memberof attribute contains your group's distinguished name, or, you can turn the logic around and ask the server to give you the member attribute of the group. The member attribute on a group contains all members' distinguished names. You can then obtain additional information about the users by reading the objects one-by-one.
Performance-wise, this is much slower, but if there is no memberof attribute on the users themselves, this might be the only option for you.
The 'memberOf' attribute is supported by the memberOf overlay, if:
you have configured it
you have modified the memberships of this DN since you installed the overlay. It isn't retrospective.

How to list users which belongs to specific group in ldap without backlink enabled

What is the search filter to list users belong to specific group like "engineering" in a ldap server which don't have backlink enabled.
For example, if backlink enabled i can use following filter,
(&(objectClass=person)(memberOf=cn=engineering,ou=Groups,o=company,o=com))
Wanted to know corresponding search query without using memberOf attribute.
Thanks
DarRay
Try your filter as:
(&(objectClass=group)(cn=engineering))
using a base of
ou=Groups,o=company,o=com
and a scope of subtree
Returning attribute "member"
Or even more efficient:
(objectClass=group)
With a base of
cn=engineering,ou=Groups,o=company,o=com
and a scope of base
Returning attribute "member"
-jim
The main question is: How are the users linked to groups?
One way is by specifying the users as attributes in the group. That can be done either via the uniqueMember- or the memberUid-Attribute. To find the users of a certain group you will have to use two queries. One query will retrieve the DNs or UIDs of the users of a group by fetching the uniqueMember or memberUid attribute of the group in question depending on your setup. Then you can retrieve the users by either using (&(objectclass=person)(uid=<uid>)) or (&(objectclass=person)(dn=<dn>)).
The other way is by storing the grous as attributes in the user, which you described above.
Hope that helps.