I need a bit of help from a bash script expert. Or at least someone who knows what they are doing.
I have used the “Zimbra content filter” wiki to build a postfix gateway server to filter bad words in emails.
This is all working ok but the problem is it is filtering a bit too much for the staff. So I have made the decision to set it up to bypass the filter for staff users.
I have looked at the new script on the “Zimbra content filter updated” wiki. This looks to be a step in the right direction as it has the functionality to have a student list in a text file and then only filters those users.
But really I want something a bit more dynamic to prevent me from having to remember to update the student list.
I was thinking instead of a student list have a staff list of users that bypass the filter and then use a LDAP search on the server to get this list instead of a text file. All of my users have the email filed populated in Active Directory on the server so this shouldn’t be a problem.
I have got my LDAP search perfected so that it pulls out the staff and admin email addresses and then pipe it into “grep” to strip out the rubbish. Below is an example of the commands I am running:
And that produces a list like followes:
ldapsearch -h sheldon.internal -p 389 -s base -b "OU=Establishments,DC=Sheldon,DC=Internal" -s sub "(&(objectCategory=user)(|(memberOf=CN=SHS Teaching Staff,OU=SHS,OU=Establishments,DC=Sheldon,DC=Internal)(memberOf=CN=SHS Non-Teaching Staff,OU=SHS,OU=Establishments,DC=Sheldon,DC=Internal) (memberOf=CN=Domain Admins,CN=Users,DC=Sheldon,DC=Internal)) (mail=*))" "mail" -D "SHELDON\ldapbind" -w "mypassword" | grep mail:
So my question is how do I pull it all together? I know it’s got something to do with “grep” and possibly some string manipulation but I have no idea where to start.
Can someone please help.