/// <summary> /// If this group has associated IP addresses does the specified IP address /// fall within the defined range. /// </summary> /// <param name="ipAddress"></param> /// <returns></returns> public bool ContainsIP(string ipAddress) { if (ipAddress == "") { return(false); } // Convert the supplied IP address to a .NET IPAddress try { // If no starting IP then no match for sure if (this.StartIP == "") { return(false); } // OK break the start and end IP address into individual entries string[] startIpAddresses = this.StartIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); string[] endIpAddresses = this.EndIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); // ...and check if the IP address we have supplied fits into that range for (int index = 0; index < startIpAddresses.Length; index++) { if ((IPAddressComparer.IsGreaterOrEqual(ipAddress, startIpAddresses[index])) && (IPAddressComparer.IsLessOrEqual(ipAddress, endIpAddresses[index]))) { return(true); } } } catch (Exception) { } return(false); }