Re: SMTP IPSecurity

From: Ralf Ziller (msmarv_at_dodgethis.de)
Date: 05/10/04


Date: Tue, 11 May 2004 00:49:25 +0200


"Stephany" <nospam@localhost> schrieb im Newsbeitrag
news:Od$6xjjMEHA.2716@tk2msftngp13.phx.gbl...
> What I would like to do is programatically add the address to the deny
list,
> but have not been able to figure out how to do this.
>
> The machine is question is running Windows 2000 Server (SP4) with Exchange
> Server 2000 (SP3) and the dev. tools of choice are C# or VB.NET (VS 2003).
>
> Can anyone provide a code fragment that will point me in the right
> direction?

The following C#-code uses System.Management, System.DirectoryServices and
System.Reflection

DirectoryEntry SMTPServer = new
DirectoryEntry("IIS://localhost/SMTPSVC/1");
SMTPServer.RefreshCache();
object oIPSecurity = SMTPServer.Invoke("Get", new string[]{"IPSecurity"});
Type t = oIPSecurity.GetType();
//Get the list of denied IPs
Array IPs = (Array)t.InvokeMember("IPDeny",
BindingFlags.GetProperty, null, oIPSecurity, null);
//create a new Array of IPs
object[] newIPs = new object[IPs.Length+1];
//copy the existing IPs to the new Array
IPs.CopyTo(newIPs,0);
//add a new value
newIPs.SetValue("192.168.0.21",IPs.Length);
//Set the new IPlist
t.InvokeMember("IPDeny",
BindingFlags.SetProperty, null, oIPSecurity, new object[]{newIPs});
SMTPServer.Invoke("Put", new object[]{"IPSecurity", oIPSecurity});
SMTPServer.CommitChanges();



Relevant Pages

  • Setting IPGrant on a folder from a WebMethod
    ... I want to be able to limit access to a folder in IIS by IP address. ... object oIPSecurity = defaultRoot.Invoke("Get", new ... //Get the list of granted IPs ... //create a new Array of IPs ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: SMTP IPSecurity
    ... DirectoryEntry SMTPServer = new ... //Get the list of denied IPs ... //create a new Array of IPs ... BindingFlags.SetProperty, null, oIPSecurity, new object); ...
    (microsoft.public.exchange2000.development)
  • Re: SMTP IPSecurity
    ... DirectoryEntry SMTPServer = new ... //Get the list of denied IPs ... //create a new Array of IPs ... BindingFlags.SetProperty, null, oIPSecurity, new object); ...
    (microsoft.public.exchange2000.general)
  • Re: SMTP IPSecurity
    ... DirectoryEntry SMTPServer = new ... //Get the list of denied IPs ... //create a new Array of IPs ... BindingFlags.SetProperty, null, oIPSecurity, new object); ...
    (microsoft.public.exchange2000.admin)
  • Re: Retrieve an element from an array
    ... >> I'm writing my personal firewall from scratch using bash 2.05b and>> iptables...The script I'm attempt to write must set automatically default>> rules for ips, respective interface and network or>> set more restrictive rules for individual ips (but that later as I'll figure>> out how to solve the problem with retrieving an array called by a string ... >> #Number of interfaces to maintain by firewall ... >> # The lines below defines the interface of which the firewall will take care>> of. ... > array with that name. ...
    (comp.unix.shell)