Re: [Mimedefang] search perl code perl-ldap to see if a user exist + how use bogofilter + problem clamav failed with testvirus.org ?
On Fri, 2 Apr 2004, jean-marc pouchoulon wrote: > I 'd like also to ask our ldap server with perl-ldap , if a user exist > before accepting mail. If someone did it That's actually quite simple, but depends on your local setup. I guess, your users uses unique account names, usually storred in the "uid" attribute, hence, you can do this: use Net::LDAP; use Net::LDAP::Entry; # Setup some vars for easy adjusting my $ldapBase = "dc=fh-bonn-rhein-sieg,dc=de"; my $ldapBaseGroups = "ou=groups,dc=fb02,$ldapBase"; my $ldap = Net::LDAP->new('localhost') or die "$@"; $ldap->bind;# anon bind sub getAccount ($) { my $name = $_[0]; my $req = $ldap->search ( # perform a search base => $ldapBase , filter => "(&(objectClass=posixAccount)(uid=$name))" ); $req->code && die $req->error; if($req->count > 1) { mylog( "$_[0] matches more than on account"); return undef; } return undef if $req->count == 0; return $req->pop_entry; } Above function returns the Net::LDAP::Entry object for the user, or undef on error (not found or found multiple entries). On big problems (connection to server fails etc.) die function die's -> here you should adjust to something more useful in the MIMEDefang filter. Depending on your local setup you must adopt the "filter" in ldap->search(). If all your users are located in the same scope, try openDN: sub openDN ($;$) { my $myLdap = $_[1] || $ldap; my $mesg = $myLdap->search(base => $_[0] , scope => 'base' , filter => 'objectclass=*' ); return undef if $mesg->code; die "Multiple search results fetching one item: " . $_[0] . "\n" if $mesg->count > 1; return $mesg->pop_entry; } The first parameter needs to be the fully qualified DN of the user. BTW: The "die" in this function should never trigger, because unless your server is broken, it can return one entry at maximum. Bye, -- Steffen Kaiser ___ Visit http://www.mimedefang.org and http://www.canit.ca MIMEDefang mailing list [EMAIL PROTECTED] http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Re: [Mimedefang] search perl code perl-ldap to see if a user exist +how use bogofilter + problem clamav failed with testvirus.org ?
Please be more explicit in giving information regarding your questions. What versions of mimedefang/clamav. What testviruss tests failed. what clamav.conf configuration, etc. the archive have ldap code to check if a sender exists before accepting it. I would really only do this if you were getting a large number of email to non existent users. In my situtaion I don't get enough of this type of email to justify ldap lookups. jean-marc pouchoulon said: > Bonjour, > I 'd like also to ask our ldap server with perl-ldap , if a user exist > before accepting mail. If someone did it > I have also some problems with mimedefang and clamav. A lots of test > from www.testvirus.org failed. I saw in the archive that the "problem" > wa referenced > without clear answers( or I don't understand) . It works correctly with > clamav-milter. no more answers ? -- Luke Computer Science System Administrator Security Administrator,College of Engineering Montana State University-Bozeman,Montana ___ Visit http://www.mimedefang.org and http://www.canit.ca MIMEDefang mailing list [EMAIL PROTECTED] http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
[Mimedefang] search perl code perl-ldap to see if a user exist + how use bogofilter + problem clamav failed with testvirus.org ?
Bonjour, Does anyone use bogofilter with mimedefang and of course how ? or simply with milter ( bogofilter-milter don't seem to work on a mail gateway). I 'd like also to ask our ldap server with perl-ldap , if a user exist before accepting mail. If someone did it I have also some problems with mimedefang and clamav. A lots of test from www.testvirus.org failed. I saw in the archive that the "problem" wa referenced without clear answers( or I don't understand) . It works correctly with clamav-milter. no more answers ? thanks jean-marc. ___ Visit http://www.mimedefang.org and http://www.canit.ca MIMEDefang mailing list [EMAIL PROTECTED] http://lists.roaringpenguin.com/mailman/listinfo/mimedefang