Deletion of list of user based on a text file In LDAP UNIX server


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deletion of list of user based on a text file In LDAP UNIX server
# 1  
Old 11-19-2015
Deletion of list of user based on a text file In LDAP UNIX server

Dear All,

It would be really nice, if you could help me to write a script for deletion of list of user( more than 15000 users) stored in a file and sorted by email address( i need deletion of only a particular type of mail address).

Is the any script to write and take the file as input and delete the user from our LDAP data base( LDAP data base is based on Linux Server).

I used to search user through:
Code:
ldapsearch  -h hostname -p XX  -D "cn=Directory Manager" -w XXX "email=ABC@dxyz.com" -b "O=XXX AG,c=XX"

We can delete ldapdele or ldapmodify for deletion, it script is based on this command it would be nice.

Please reply me soon, waiting for your valuable reply.

Thanks in Advance.
Chand

Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 11-19-2015 at 05:03 AM..
# 2  
Old 11-19-2015
Please use code tags in future when posting commands, logs, data etc. I have changed this in your post already.

You might want to use a loop like a while/read around the command ldapdelete and feed it with that list.
Though to be better safe than sorry you will have a small list of users to delete (let's say 3 of them), instead of all 15.000.

Here you can find the syntax: The ldapsearch, ldapdelete and ldapmodify utilities

It will basically look like this, where you have to change the list and the echo to ldapdelete with the correct command switches etc.:
Code:
$ cat infile
will
martha
pete
$ while read LINE; do echo $LINE; done < infile
will
martha
pete

# 3  
Old 11-19-2015
Thanks for you replay. I guess, my concern is not still resolved.
Let me explain you a bit details, so that you get some idea to help me better.

I have searched the user for particular email address based, then used below command.
Code:
grep "^dn:" XYZ_Backup.ldif | sed 's/^dn: //' >delete_Peoples.ldif

it is giving me the list of user which are supposed to delete from O=AN AG,C=EE, example
Code:
EMAIL=abc.123@dxy.com,O=AN AG,C=EE
----
----
---

15000 entires....

And this also as DN: EMAIL=abc.123@dxy.com,O=AN AG,C=EE

Please advice me based on looping only script to delete the user from linux servers whole 15000 user without distubing other users in LDAP.

Reagrds,
CHand

Last edited by zaxxon; 11-19-2015 at 11:33 AM..
# 4  
Old 11-19-2015
I think it still will work like what I posted before. If you did not understand what I wrote or what particular is not matching your request, say so please.
You will have to write the mini script yourself.

Also I asked you to use code tags, which you still don't do so you can use the automatic PM with instructions how and when to use code tags.

If you have a list of users with their dn, then try to use it in the way I have shown already. As also said already, start with maybe 3 users, to not kill any other user account.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

User Based LDAP Client Access

Hi everyone, I am not that familiar with LDAP advanced contents. But since it is a popular secure tool for authentication, I preferred to user RedHat LDAP. The organization has 5 organizational units. There are 3 client servers and I want to limit each client to access different users. So, I... (3 Replies)
Discussion started by: royalliege
3 Replies

2. UNIX for Dummies Questions & Answers

print multiple lines from text file based on pattern list

I have a text file with a list of items/patterns: ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig12238 ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig34624... (1 Reply)
Discussion started by: Oyster
1 Replies

3. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

4. UNIX for Dummies Questions & Answers

Script for replacing text in a file based on list

Hi All, I am fairly new to the world of Unix, and I am looking for a way to replace a line of text in a file with a delimited array of values. I have an aliases file that is currently in use on our mail server that we are migrating off of. Until the migration is complete, the server must stay... (8 Replies)
Discussion started by: phoenixjc
8 Replies

5. Shell Programming and Scripting

Unix ldapsearch can not contact a Windows LDAP Server

Good morning, Firstly my appologies if this post is not exactly approprate for this forum but I do not know were else to post it. If anyone knows of a better forum for this please let me know. I need to script an ldapsearch that will interrogate both unix and windows ldap servers. When it... (1 Reply)
Discussion started by: twk
1 Replies

6. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies

7. Shell Programming and Scripting

Deletion of lines in a text file

Hi Everyone, Please help me with this. I have gone through many posts here but couldn't find what I wanted. I have a file with 79000+ lines and I want to delete lines in a pattern. I want to delete every 141st line in the file, starting from line 2000 till 50000. Please help guys. ... (8 Replies)
Discussion started by: max29583
8 Replies

8. Solaris

Script for automatic deletion of trash file of mail server

Hi, I have a mail server with limited space and operating system is sun solaris 8 (sparc). I do not have provisions to increase the space for home directory. So i have to delete files from /home/username/mail/trash which are more than 10 days old automatically. So my script should be like... (1 Reply)
Discussion started by: crown2100bd
1 Replies

9. Shell Programming and Scripting

File deletion when server restarts

Hi, In a shell script I am makin use of 3 files f1,f2 and f3.txt. When the Unix server is restarted I want to delete all these 3 files if they are existing. ( I suppose I will have to use this command rm /thefilepath/f* but dont know in which script to use.) Anyone knows what can be... (6 Replies)
Discussion started by: k_oops9
6 Replies
Login or Register to Ask a Question