ldapsearch bash script help

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat ldapsearch bash script help
# 1  
Old 10-19-2010
ldapsearch bash script help

Hi there everyone. I'm trying to make a bash script that accepts some arguments ans give's back some info about LDAP users and servers.

I have this function :

Code:
has_group_access(){

result=$(ldapsearch -LLL "cn=${GROUP_NAME}" cn member | cut -d"," -f1 | cut -d":" -f2 | cut -d"=" -f2 | grep -v ${GROUP_NAME} | grep -v ${dummy})

          for item in $result
          do
                  if [ "$item" == $(hostname) ];then
                          echo "Le groupe:[ ${GROUP_NAME} ] a l'acces sur la machine:[ $(hostname) ]"
                          echo "\n"
                 else
                         echo "Le group : [ ${GROUP_NAME} ] n'as pas acces sur cette machine"
                  fi
          done
          #echo ${result}
          exit 0
 }

What I want is to search in the return value if the hostname (the actual server that executes the script) is in the list.
And if it is it means that the group can access this machine.

How can I do that ?
Thank you for your help.
This is rely important for my job.

---------- Post updated 10-19-10 at 08:09 AM ---------- Previous update was 10-18-10 at 04:06 PM ----------


And how can I query the LDAP server for all the users to see the hosts that they have access to, and after parse this info to show all the users that have access to the running system that will execute the script ?

Thank you for your help

Last edited by theboogymaster; 10-19-2010 at 05:14 AM..
# 2  
Old 10-19-2010
Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Moderator's Comments:
Mod Comment
You also have a thread about this already - next time maybe just continue the thread about the same topic. No need to open up a new thread with the same topic (LDAP Script).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Red Hat

Ldapsearch problem

Hi I'm not familiar with ldap and I hope someone to help me. I need to get some attribute value from ldap DB. When i run the following command is OK: ldapsearch -h localhost -p 16611 -x -D cn=user -w passwd -b msisdn=359502479649,dc=MSISDN,DC=C-NTDB "(objectClass=SUBINNSS)" refinmocNAME the... (0 Replies)
Discussion started by: vasil
0 Replies

3. Shell Programming and Scripting

useless line feeds in ldapsearch output. Howto remove with shell script?

Hi $ cat ad.sh ldapsearorg -x -LLL -h sb1131z.testbadbigcorp.org -D "CN=ADMINZZ,OU=AdminRoles,DC=testbadbigcorp,DC=org" -w "UT3w4f57lll--4...4" -b "OU=Test,DC=testbadbigcorp,DC=org" "(&(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295)))))" dn$... (3 Replies)
Discussion started by: slashdotweenie
3 Replies

4. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

5. UNIX for Dummies Questions & Answers

Need assistance on using ldapsearch

Never knew of this command ldapsearch, but I would like to use it to lookup a single user and return where their office is. Is this possible? I'm totally starting from scratch. I already saw some of the gurus say read the man page, which is pretty greek when you don't know the details of... (1 Reply)
Discussion started by: srhadden
1 Replies

6. AIX

ldapsearch to find DN for a user

How can I do a ldapsearch to find a DN for a user when I know the exact cn for that user out of active directory. I have tried several different commands (hundreds) but need the -b with the full dn to perform the search using ldapsearch from AIX. I am trying to find the OU for a user and the... (3 Replies)
Discussion started by: cchart3
3 Replies

7. Programming

LDAPSEARCH in C

Hi all, I've been searching for ldapsearch function these few days. Still I couldn't found the solution. I would like to translate this query ldapsearch -x -LLL -h new_IP -p new_Port -D "cn=jw" -w "dummy" -b "id=2311,o=WC,c=jp" -s sub to ldap_search_ext_s() function in C program. ... (0 Replies)
Discussion started by: tailangong
0 Replies

8. UNIX for Advanced & Expert Users

Counting the ldapsearch results

Hi, Is there way to count the number of results in the ldapsearch, looking at the manpages i dont see an option, Using the following ldapsearch command to list attribute (User-Id=100) under my ObjectClass=my-Process, returns the entries matching the User-Id=100, and the problem i face here is... (0 Replies)
Discussion started by: ennstate
0 Replies

9. UNIX for Advanced & Expert Users

ldapsearch and XML

Hello all I would like to know if it's possible to extract users from Active Directory and parse the output to obtain a XML file with specific format. So the AD is a windows machine, and I would like to extract from a red hat linux serveur. I try ldapsearch command and ok I'm abble to extract... (5 Replies)
Discussion started by: ldiaz2106
5 Replies

10. IP Networking

Help Needed regarding Ldapsearch script

Hi guys, I very appreciate for answering to my previous query. I have encountered another problem.I have a perl script to display required networking information like DNS,gateway,etc. to be changed in a remote computer which is to be added to a computing cluster. I need a script which... (0 Replies)
Discussion started by: pranav.mehta3
0 Replies
Login or Register to Ask a Question