WinForm Development Framework's rights Management System Improvement experience Summary (3) system login black and white list realization

Source: Internet
Author: User
Tags bool

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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.