LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   return ldap group name of user (https://www.linuxquestions.org/questions/linux-newbie-8/return-ldap-group-name-of-user-4175649668/)

rufa 03-06-2019 04:55 PM

return ldap group name of user
 
Hello,
Sorry i'm new with ldapsearch,

With the following command i can return the dn group name of user, but i want to retuen only the group name or gid without other information:
Code:

ldapsearch -h ipaserver.example.com -p 389  -x -b "dc=example,com"  "(&(objectClass=posixGroup)(memberUid=test-user))" dn
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> with scope subtree
# filter: (&(objectClass=posixGroup)(memberUid=test))
# requesting: dn
#

# jabber_users, groups, compat, example.com
dn: cn=jabber_users,cn=groups,cn=compat,dc=example,dc=com

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Can someone help please !

bathory 03-07-2019 05:42 AM

Hi,

I guess you want to get just "cn=jabber_users" from the whole ldapsearch output.
If that's the case, you could try something like:
Code:

ldapsearch -h ipaserver.example.com -p 389  -x -b "dc=example,com"  "(&(objectClass=posixGroup)(memberUid=test-user))" dn|grep -o 'cn=.*'|cut -d',' -f1
Regards

rufa 03-07-2019 09:00 AM

Hi bathory,
Thank you for the quick reply,

This query will be used in freeradius authentication and i'm not sure if grep works in freeradius query ?

Thanks,


All times are GMT -5. The time now is 08:43 AM.