ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to write a shell script to do the following , would advise how to make it ? very thanks
1. Connect LDAP server ( Id : user , password : pass )
2. check the field "user_account_create_date" in the LDAP server , the format of data in this field in LDAP is ABC20130922 ( 22 Sep , 2013) , find the record in this field to check last 8 digits , if the date is within 7 days ( that mean the account is created within 7 days ), then do ...
could advise what to make this script ?
thanks
Last edited by byran cheung; 09-22-2013 at 07:04 PM.
As for the specific script that you want, the following is an LDAP Query Script that might give you the baseline for accomplishing what you need http://daverdave.com/node/9
As for the specific script that you want, the following is an LDAP Query Script that might give you the baseline for accomplishing what you need http://daverdave.com/node/9
Hi sxa ,
I am new to shell writing , would you please advise a simple sample ? thanks
Distribution: Mac OS 10.7 / CentOS 6(servers) / xubuntu 13.04
Posts: 1,186
Rep:
Below is a sample bash script using ldapsearch, I don't have access to an LDAP server at the moment to test the ldapsearch command, but this will find all users that were created since the timestamp. Using the date command we look for the time stamp exactly 7 days from your current system date.
Again, you will need to modify the ldapsearch command with your proper IP and credentials for your LDAP server but this will output the users that have been created since the timestamp to the specified.
You said you want to do an action against these users, you would want to start by researching the various ways to read files in bash. You don't specify what action you want to do take, and the best approach will vary based on that action, but I hope this and the links provided will give you a starting point.
Below is a sample bash script using ldapsearch, I don't have access to an LDAP server at the moment to test the ldapsearch command, but this will find all users that were created since the timestamp. Using the date command we look for the time stamp exactly 7 days from your current system date.
Again, you will need to modify the ldapsearch command with your proper IP and credentials for your LDAP server but this will output the users that have been created since the timestamp to the specified.
You said you want to do an action against these users, you would want to start by researching the various ways to read files in bash. You don't specify what action you want to do take, and the best approach will vary based on that action, but I hope this and the links provided will give you a starting point.
About the above requirement 2 " check the field "user_account_create_date" in the LDAP server , the format of data in this field in LDAP is ABC20130922 ( 22 Sep , 2013) , find the record in this field to check last 8 digits , if the date is within 7 days ( that mean the account is created within 7 days ), then do ..." ,
how to write this part of script ? anyone can advise , thanks
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.