LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-14-2008, 08:19 AM   #1
Buddhike G
Member
 
Registered: Jun 2007
Distribution: RHEL, CentOS, Solaris
Posts: 63

Rep: Reputation: 16
shell scrip to read ldap user details


hi

I'm trying to add a shared address book to my squirrelMail web interface. For that i have to fetch name,surname,email,nickname and additional info of the all the users in the ldap database and write them into a local file. can anybody please give me a example shell script for doing above task ??
( since I'm not familier with LDAP it's really a big task to me !)

Thanks in Advance.
 
Old 05-14-2008, 08:50 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You can use ldapsearch to query ldap. Running:
Code:
ldapsearch -x -b 'dc=domain,dc=com' '(objectclass=*)'
will give you all the entries. You can the refine your search to the attributes you want, like:
Code:
ldapsearch -x -b 'dc=domain,dc=com' '(objectclass=*)' name cn sn mail
 
Old 05-14-2008, 09:43 AM   #3
Buddhike G
Member
 
Registered: Jun 2007
Distribution: RHEL, CentOS, Solaris
Posts: 63

Original Poster
Rep: Reputation: 16
Thanx a lot for the quick reply !!

Does following command give details of all the users in the ldap database ?

ldapsearch -x -h hostname -b 'dc=domain,dc=com' '(objectclass=*)' nickname cn sn mail telephoneNumber


Currently I don't have access rights to the ldap server. since i can't imagine how the output of the above command would be.

so can any one please give me a example shell script to store the output of the above command in following manner for each user in a text file.

nickname|firstname|surname|email|telephonenumber

or else the format of the output of the above command

Thanks in Advance !
 
Old 05-15-2008, 01:57 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
ldapsearch -x -h hostname -b 'dc=domain,dc=com' '(objectclass=*)' nickname cn sn mail telephoneNumber
Currently I don't have access rights to the ldap server. since i can't imagine how the output of the above command would be.
The output of the above command is like this:

# uid, people, domain.com
dn: uid=user,ou=people,dc=domain,dc=com
sn: surname
mail: user@domain.com
cn: common-name
nickname: whatever
telephoneNumber: 12345

I guess someone with good scripting knowledge could make a script from the above output to help you do what you want.

Regards
 
Old 05-24-2008, 09:00 AM   #5
Buddhike G
Member
 
Registered: Jun 2007
Distribution: RHEL, CentOS, Solaris
Posts: 63

Original Poster
Rep: Reputation: 16
Thanx a lot !
 
  


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
List all user details nutthick Linux - Newbie 7 01-14-2013 02:46 AM
Open LDAP shows details with anonymous authentication only nolinuxnollife Linux - Software 0 07-22-2007 11:58 PM
LDAP server not starting as user LDAP klnasveschuk Fedora 1 02-15-2007 04:49 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM
Maillog Details (how to read them?) Kaj Linux - General 1 09-22-2003 08:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:44 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