ldapsearch - extract 'sudo su' users with awk or sed.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ldapsearch - extract 'sudo su' users with awk or sed.
# 1  
Old 11-16-2011
ldapsearch - extract 'sudo su' users with awk or sed.

Hello all,

Hope you all are doing good
Smilie.
First of all, I apologize for my bad English

I want to get list of all user that have
'sudoCommand: ALL'
I've tried different sed and awk combinations without success Smilie


the command for extracting the OU for sudo is:
Code:
ldapsearch -x -b "ou=SUDOers,dc=domain,dc=loc"

Output:

Code:
PROJECT1, SUDOers, domain.loc
dn: cn=PROJECT1,ou=SUDOers,dc=domain,dc=loc sudoCommand: /bin/su - oracle objectClass: top objectClass: sudoRole sudoHost: server1 sudoOption: !authenticate sudoUser: user1 sudoUser: user2 sudoRunAs: root cn: PROJECT1 parentid: 2 entryid: 250
# Project3, SUDOers, domain.loc
dn: Project3,ou=SUDOers,dc=domain,dc=loccn: Project3
sudoOption: !authenticate
objectClass: sudoRole
sudoHost: server1
sudoHost: server2
sudoHost: server3
sudoHost: server4
sudoCommand: ALL
sudoRunAs: root
sudoUser: user7
sudoUser: user5
parentid: 2
entryid: 237 # PROJECT2, SUDOers, domain.loc dn: cn=PROJECT2,ou=SUDOers,dc=domain,dc=loc sudoUser: user3 sudoHost: server2 objectClass: top objectClass: sudoRole sudoCommand: ALL sudoRunAs: root cn: PROJECT2 parentid: 2 entryid: 251 # search result search: 2 result: 0 Success # numResponses: 32 # numEntries: 31



I need only the sudo user that have sudo su (sudoCommand: ALL)
the output is very long so I posted here only 3 paragraph.

thanks all

# 2  
Old 11-16-2011
did you try with grep
Code:
ldapsearch -x -b "ou=SUDOers,dc=domain,dc=loc"|grep sudoCommand

# 3  
Old 11-16-2011
Quote:
Originally Posted by ygemici
did you try with grep
Code:
ldapsearch -x -b "ou=SUDOers,dc=domain,dc=loc"|grep sudoCommand

ygemici, thx for reply.
This is not help me.
I need search paragraph that have
sudoCommand: ALL
sudoUser: user7

Together.

for short I need to know who have sudo su command.
Thx
# 4  
Old 11-16-2011
You can try adding a filter at the end of the command:

Code:
ldapsearch -x -b "ou=SUDOers,dc=domain,dc=loc" "(&(objectclass=sudoRole)(sudoCommand=ALL))"

This should show only the users that have the above attribute set. You can then grep the output for "sudoUser".
# 5  
Old 11-16-2011
Quote:
Originally Posted by zaxxon
You can try adding a filter at the end of the command:

Code:
ldapsearch -x -b "ou=SUDOers,dc=domain,dc=loc" "(&(objectclass=sudoRole)(sudoCommand=ALL))"

This should show only the users that have the above attribute set. You can then grep the output for "sudoUser".
Thank you very very much !
i'm very appreciated your help!
Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk/sed command to extract the string between 2 patterns but having some particular value

Hi - i have one file with content as below. ***** BEGIN 123 ***** BASH is awesome ***** END ***** ***** BEGIN 365 ***** KSH is awesome ***** END ***** ***** BEGIN 157 ***** KSH is awesome ***** END ***** ***** BEGIN 7123 ***** C is awesome ***** END ***** I am trying to find all... (4 Replies)
Discussion started by: reldb
4 Replies

2. Shell Programming and Scripting

sed / awk / grep to extract information from log

Hi all, I have a query that runs that outputs data in the following format - 01/09/12 11:43:40,ADMIN,4,77,Application Group Load: Name(TESTED) LoadId(5137-1-0-1XX-15343-15343) File(/dir/dir/File.T03.CI2.RYR.2012009.11433350806.ARD) InputSize(5344) OutputSize(1359) Rows(2) Time(1.9960)... (8 Replies)
Discussion started by: jeffs42885
8 Replies

3. Shell Programming and Scripting

Awk/sed HTML extract

I'm extracting text between table tags in HTML <th><a href="/wiki/Buick_LeSabre" title="Buick LeSabre">Buick LeSabre</a></th> using this: awk -F "</*th>" '/<\/*th>/ {print $2}' auto2 > auto3 then this (text between a href): sed -e 's/\(<*>\)//g' auto3 > auto4 How to shorten this into one... (8 Replies)
Discussion started by: p1ne
8 Replies

4. Shell Programming and Scripting

Extract info and do algebra on it by sed or awk

Hello everyone, I need to extract some information from a csv file and further need to do some algebraic calculations on those information and then to throw the result in a new file. Here is a sample from my data.csv file; Col1,Col2,Col3,Col4,Col5,Col6,Col7... (19 Replies)
Discussion started by: hayreter
19 Replies

5. Shell Programming and Scripting

Extract a substring using SED/AWK

Hi All, I have a log file in which name and version of applications are coming in the following format name It may look like following, based on the name of the application and version: XYZ OR xyz OR XyZ OR xyz I want to separate out the name and version and store them into variables.... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

6. Shell Programming and Scripting

Extract word from text (sed,awk, etc...)

Hello, I need some help extracting the number after the RBA e.g 15911688 from the below block of text (e.g: grep RBA |sed .......). The code should be valid for blocks if text generated at different times as well and not for the below text only. ... (2 Replies)
Discussion started by: drbiloukos
2 Replies

7. UNIX for Dummies Questions & Answers

Using awk/sed to extract text between Strings

Dear Unix Gurus, I've got a data file with a few hundred lines (see truncated sample)... BEGIN_SCAN1 TASK_NAME=LA48 PDD Profiles PROGRAM=ArrayScan 1.00 21.220E+00 2.00 21.280E+00 END_DATA END_SCAN1 BEGIN_SCAN2 TASK_NAME=LA48 PDD Profiles 194.00 2.1870E+00 ... (5 Replies)
Discussion started by: tintin72
5 Replies

8. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies

9. Shell Programming and Scripting

Extract some characters with SED or AWK

Hi, I have the following example string: today_is_a_good_day.txt The character "_" inside the string can sometimes be more or less. The solution for every string equal the count of "_" should be alway the rest after the last underline character. Result: day.txt I want to use awk... (5 Replies)
Discussion started by: climber
5 Replies

10. Shell Programming and Scripting

extract using sed/awk - need help? Please!!

Need help..not sure how to use with awk or sed I want to take data from the notification.$$ file and assign the data to variable "group". Not sure how to do it. The data I want to extract from the notification.$$ is on the first line of the file ..right after the (notice): NetWorker... (5 Replies)
Discussion started by: gzs553
5 Replies
Login or Register to Ask a Question