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

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)))

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 to check if User is a member of a particular security group

I am trying to adapt the following query to find out if a user is a member of a specific group (security group) but I do not get it to work and I fail to understand it completely.
(&(objectClass=user)(sAMAccountName=yourUserName)
(memberof=CN=YourGroup,OU=Users,DC=YourDomain,DC=com))
in my case, the user is XYZ and the security group is called [SecITGroup].
The user is however located under OU=USERS OU=GO OU=AzureSync.
I have tried the following:
(&(objectClass=user)(sAMAccountName=XYZ)
(memberof=CN=SecITGroup,OU=AzureSync,OU=GO,OU=USR,DC=de,DC=domain,DC=int))
yes, I set the domain name to the actual domain and No result is shown is displayed.
What is the return attribute am I supposed to get back?
I found a solution or a workaround to this.
The LDAP Query is rather to say show me users in the specific group:
(&(objectCategory=user)(memberOf=CN=Administrators,OU=Admin,OU=Groups,DC=domain,DC=com))
The attribute is sAMAccountname which displays the user's name.

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

Searching for a user and associated groups on LDAP in one search

New to LDAP. The way our LDAP is arranged is People and groups. The people have user information such as name, uid, and mail. The groups have group name and multiple member field which has value like cn=First Last,cn=people,dc=comic,dc=com, listing the People that are members of the group.
Currently starting with userid and password, doing two searches:
1) Get user by searching on People base domain on uid=value. Then from the user get the first and last name.
2) Search on Groups base domain based on member=cn=First Last,cn=People,dc=comic,dc=com and iterate over the list of group objects returned to the group name field.
Am just wondering is there way to do all this in one search or are two searches necessary?
Unfortunately you cannot do what would like in one operation.
Also, what you are doing will not always work. Instead of retrieving the users first and last name you should retrieve their distinguished name (dn attribute) and do your group search based on that. First and last names can be modified within LDAP and can happen due to marriage / divorce / etc.
It is possible, provided that you implement a Reverse Group Membership Maintenance Overlay.
To determine which groups an entry is a member of without performing extra searches, the memberOf overlay is exactly what you need.
The memberof overlay updates an attribute (by default memberOf)
whenever changes occur to the membership attribute (by default member)
of entries of the objectclass (by default groupOfNames) configured to
trigger updates. Thus, it provides maintenance of the list of groups
an entry is a member of, when usual maintenance of groups is done by
modifying the members on the group entry.
You may find this Server Fault post useful for a how to.
Once you have memberOf attribute ready to be used, you may have to run ldapmodify manually on each group entries, but just once, so that all members entries can be provisioned with the corresponding group dn in their respective memberOf attribute.
Finally, to perform a group membership search for a given user, you would just search for the user entry and iterate the memberOf attribute to get group dn's.

Reduce Active Directory users in Jira using LDAP Query

I am retrieving users for Active directory in Jira 7 by using LDAP. I am trying to reduce the number of users brought from LDAP to a particular group that we have created. So in order to do that i put (objectCategory=group)(cn=WebAgileDevs) in the group object filter along with the default settings. The only thing i change is the Base DN and credentials required. When i save and test it does show me that it is testing 1 group and 15 users which is what i want!(See the screenshot). BUT, when i go and sync it, it brings in 43000 users!! What am i missing???
Test Remote Directory Screenshot
The group filter is used to filter the list of groups that are imported to JIRA, and the user filter is used to filter the list of users that are imported to JIRA. The two need not necessarily correspond. Your group filter would be instructing JIRA to bring in only that one group (into the list of groups), but without further refinement, your user filter will still be pulling in all users, as you noticed. This means that you need to adjust the user filter too.
From your question, you want to import only those users who are a member of a specific group. Atlassian provides some general guidance here.
The last example on that page is particularly relevant for you:
(&(objectCategory=Person)(sAMAccountName=*)(memberOf=cn=CaptainPlanet,ou=users,dc=company,dc=com))
This tells JIRA to pull in only those user objects that are a member of the group cn=CaptainPlanet,ou=users,dc=company,dc=com. You would want to replace this with your cn=WebAgileDevs (plus whatever trailing qualifiers you need to fully qualify the group name).