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/devguide/index.html?modifying_and_creating_banned_ips.htm