Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

IIS SMTP automated access connection configuration...

Back to Forum: Tech Off
  • User profile image
    xlouk

    Hi,

    with .NET 2.0 and the new mailing class System.Net.Mail, sending mails by using an installed IIS SMTP server has new behaviour. It is now requiered to configure the Access\Connections... and \Relay... settings (enabling localhost 127.0.0.1) to allow access from the localhost. Otherwise mails are not sent.

    Since we use XP Embedded, this should be done on an automated way. Does anybody know, how this setting (IIS SMTP Access\Connections... and \Relay... ) could be accomplished? I could not find a registry settings or programming interface todo so.


    Regards,

    xlouk

  • User profile image
    xlouk

    The following Visual Basic Script does the job:

    '########################################################################################
    '# VBS script sets access rights of the IIS 5.1 Virtual SMTP Server so, that EMails can be
    '# send using the new .NET 2.0 class System.Net.Mail.
    '# Important: Before using this script, backup your Metabase.bin located in
    '# C:\WINDOWS\system32\inetsrv
    '# Helpfull tool to check the metabase is the Metabase Explorer contained in the IIS 6.0
    '# Resource Kit:
    '# http://www.microsoft.com/downloads/thankyou.aspx?familyId=56fc92ee-a71a-4c73-b628-ade629c89499&displayLang=en&oRef=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fresults.aspx%3fpocId%3d%26freetext%3dmetabase%2520explorer%26DisplayLang%3den
    '# For a Metabase Reference look here:
    '# http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/13ca169c-c1ec-4056-b75e-8c62866b8e91.mspx?mfr=true
    '########################################################################################

    Dim NewIP
    Dim i

    ' Obtain SMTP Server object
    Dim IIsSmtpSvrObj
    Set IIsSmtpSvrObj = GetObject("IIS://localhost/SMTPSVC/1")

    ' IP entry for White List
    NewIP = "127.0.0.1,255.255.255.0"

    '----------------------------------------------------------
    ' Configure RelayIpList access right of SMTP Servers
    '----------------------------------------------------------
    Dim MyRelayIpList
    Dim RelayIpList
    Dim RelayIPAdd

    ' Load current IP Security settings
    Set MyRelayIpList = IIsSmtpSvrObj.RelayIpList

    ' Add NewIP to White List, if not allready set
    MyRelayIpList.GrantByDefault = False
    RelayIpList = MyRelayIpList.IPGrant
    RelayIPAdd = "YES"
    Redim Preserve RelayIpList (Ubound(RelayIpList)+1)

    ' Check for existens of NewIP in White List, because doubled entries causes
    an error
    For i = 0 to UBound(RelayIpList)
     If RelayIpList(i) = Replace(NewIP,",",", ") Then
      RelayIPAdd = "NO"
    '  MsgBox("IP Restriction already set")
     End If
    Next

    If RelayIPAdd = "YES" Then
     RelayIpList(Ubound(RelayIpList)) = NewIP

     ' Add extended IP list and pass over
     MyRelayIpList.IPGrant = RelayIpList
     IIsSmtpSvrObj.Put "RelayIpList", MyRelayIpList
    End If



    '----------------------------------------------------------
    ' Configure IPSecurity access right of SMTP Servers
    '----------------------------------------------------------
    Dim MyIPSec
    Dim IPList
    Dim IPSecAdd

    ' Load current IP Security settings
    Set MyIPSec = IIsSmtpSvrObj.IPSecurity

    ' Add NewIP to White List, if not allready set
    MyIPSec.GrantByDefault = False
    IPList = MyIPSec.IPGrant
    IPSecAdd = "YES"
    Redim Preserve IPList (Ubound(IPList)+1)

    ' Check for existens of NewIP in White List, because doubled entries causes
    an error
    For i = 0 to UBound(IPList)
     If IPList(i) = Replace(NewIP,",",", ") Then
      IPSecAdd = "NO"
    '  MsgBox("IP Restriction already set")
     End If
    Next

    If IPSecAdd = "YES" Then
     IPList(Ubound(IPList)) = NewIP

     ' Add extended IP list and pass over
     MyIPSec.IPGrant = IPList
     IIsSmtpSvrObj.Put "IPSecurity", MyIPSec
    End If

    ' Now set the complete change at the server at once
    If RelayIPAdd = "YES" or IPSecAdd = "YES" Then
     IIsSmtpSvrObj.setInfo()
    End If


    xlouk

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.