Microsoft SMTP Event Sink scripting.

  • Thread starter Sterling Anderson
  • Start date
S

Sterling Anderson

I have a customer who has a virus/spam application that registers a couple
event sinks with SMTP to check for virus infected or spam email. Right now
all the email that meets the "bad" criteria gets relayed to a catchall mail
account. Any email that passes the tests gets relayed to the real SMTP
server. The problem is, the "bad" email includes email to nonexistant
accounts at the company.

What I am in need of is an event sink that does a directory lookup with each
email and if the user is not in the domain or active directory user list
then the mail should be sent back to the sender with the standard "relaying
not allowed" error.

Can anyone help me out with this? I think I understand the whole event sink
idea but I cannot find resources on doing the user lookup.

Thanks in advnace.
 
T

Timothy H. Schilbach

Hi There,

Have you considered doing a simple directory query for each user? Here is
simple code I put togeather into a function in VB.NET togeather and this may
help ya:

Private Function FindListOwner(ByVal Name As String) As DirectoryEntry

'###############################################################

'# This will return the requested user using the email address

'###############################################################

Dim entry As New DirectoryEntry("LDAP://domain.com")

Dim mySearcher As New System.DirectoryServices.DirectorySearcher(entry)

Dim result As System.DirectoryServices.SearchResult

mySearcher.Filter = ("(&(Mail=" & Name &
"*)(objectClass=user)(objectCategory=person))") 'lookup a users rdn using
the begining of their email address

For Each result In mySearcher.FindAll()

Return result.GetDirectoryEntry

Next

End Function

If it doesnt find anything, then it doesnt exist.

-Timothy
 
D

Deji Akomolafe

Have you considered upgrading to Exchange 2003? This is one of the new
features.

HTH
Deji
 
S

Sterling Anderson

Unfortunately upgrading is not an option. Also, the server that is doing the
filtering is just acting as an SMTP relay. So it is not interfacing with
Exchange at all.
 
G

Gabe Matteson

i believe there is an option in exchange 2000, i know there is in 2003 that
allows you to say, drop all mail that is destined to an address that doesn't
exist in your organization.
 
E

Egbert Nierop \(MVP for IIS\)

Sterling Anderson said:
I have a customer who has a virus/spam application that registers a couple
event sinks with SMTP to check for virus infected or spam email. Right now
all the email that meets the "bad" criteria gets relayed to a catchall mail
account. Any email that passes the tests gets relayed to the real SMTP
server. The problem is, the "bad" email includes email to nonexistant
accounts at the company.

What I am in need of is an event sink that does a directory lookup with each
email and if the user is not in the domain or active directory user list
then the mail should be sent back to the sender with the standard "relaying
not allowed" error.

Can anyone help me out with this? I think I understand the whole event sink
idea but I cannot find resources on doing the user lookup.

Thanks in advnace.


If you send me that script, I will convert it to that functionality and send
the improved version back, if possible. Anyway, the POP3 service that comes
with windows 20003 has the same effect so it should programatically, be
achieved in win2000 as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top