Modifying and creating banned IPs

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can modify the Ban reason of an existing banned IP:

 

[C#]

 

using CMS.SiteProvider;

 

...

 

        // Get BannedIP object by IPAddressID

        BannedIPInfo bi = BannedIPInfoProvider.GetBannedIPInfo(1);

 

        // Change Ban reason property

        bi.IPAddressBanReason = bi.IPAddressBanReason + "_Updated";

 

        // Save object

        BannedIPInfoProvider.SetBannedIPInfo(bi);

 

The following sample code shows how you can create a new banned IP of type All user actions and add it to the system:

 

[C#]

 

using CMS.SiteProvider;

 

...

 

        // Create new BannedIP object

        BannedIPInfo bi = new BannedIPInfo();

 

        // Set properties

        bi.IPAddress = "127.0.0.1";

        bi.IPAddressBanReason = "Ban reason";

        bi.IPAddressAllowed = true;

        bi.IPAddressAllowOverride = true;

        bi.IPAddressBanType = BannedIPInfoProvider.BanControlEnumString(BanControlEnum.AllNonComplete);

        bi.IPAddressBanEnabled = true;

 

        // Save object

        BannedIPInfoProvider.SetBannedIPInfo(bi);

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_modifying_and_creating_banned_ips.htm