In the general permission system, you may often see the system's blacklist or whitelist interception function. In the general permission system, the common blacklist is to prohibit users to login on some IP system, the whitelist is to allow users to only on certain IP login system. This essay mainly introduces in my permission system, how to achieve this black and white list of functions, as well as the introduction in which the IP contrast operation, IP segment judgment, and other operating code.
1, the Black and white list configuration
To complete the blacklist of interception and whitelist release, we need to configure the list of operations, we put the relevant configuration into the list to display, you can add a number of blacklist or whitelist, as shown in the following interface.
You can click the New button to add a record, or double-click the black and white list on an existing record to edit it, as shown in the following screen.
2, IP section of the input and contrast
In the above IP input, we need to confirm that the IP segment start address is less than the end address, otherwise we compare, it may occur confusion, so we need to confirm the user input, that is, the size of the IP address comparison relationship.
The check code for the entry is shown below.
<summary>///functions to implement control input checking///</summary>///<returns></returns>
public override bool Checkinput () {bool = true;//By default is available through the #region Myregion if (This.txtName.Text.Trim ().
Length = = 0) {messagedxutil.showtips ("Please enter display name");
This.txtName.Focus ();
result = false; else if (this.txtAuthorizeType.Text.Length = 0) {messagedxutil.showtips ("Please select authorization
Type ");
This.txtAuthorizeType.Focus ();
result = false; else if (this.txtIPStart.Text.Length = 0) {messagedxutil.showtips ("Please enter IP start address")
;
This.txtIPStart.Focus ();
result = false;
else if (this.txtIPEnd.Text.Length = 0) {messagedxutil.showtips ("Please enter IP End address"); This.txtIPEnd.Focus ();
result = false;
} IPAddress ip1 = Ipaddress.parse (This.txtIPStart.Text);
IPAddress ip2 = Ipaddress.parse (This.txtIPEnd.Text);
if (Ip1.compare (ip2) = = 1) {messagedxutil.showtips ("Please change the IP start address is not greater than the end address, please modify");
This.txtIPEnd.Focus ();
result = false;
#endregion return result; }