LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2019, 04:55 PM   #1
rufa
LQ Newbie
 
Registered: Nov 2018
Posts: 24

Rep: Reputation: Disabled
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 !
 
Old 03-07-2019, 05:42 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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

Last edited by bathory; 03-07-2019 at 12:09 PM.
 
Old 03-07-2019, 09:00 AM   #3
rufa
LQ Newbie
 
Registered: Nov 2018
Posts: 24

Original Poster
Rep: Reputation: Disabled
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,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the group name and user name the same? zissoudo Linux - Newbie 4 11-12-2011 01:44 PM
[SOLVED] Apache authentication: allow LDAP group OR user named guest, but not all LDAP users AlucardZero Linux - Server 1 05-25-2011 03:21 PM
Block bitmap for group 416 not in group (block 0) + group descriptors corrupted? quanta Linux - Server 1 12-08-2010 10:40 AM
group: add complete group into other group max_mad SUSE / openSUSE 1 04-12-2006 01:43 AM
Group Admin, Group Root, or God over Group crickett Linux - General 5 07-12-2004 04:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration