Link to home
Start Free TrialLog in
Avatar of flukester
flukester

asked on

compare single ip to ip range

I want to allow access to a certain folder based on IP address. I can get the IP address from user and check it and all that good stuff.
The problem is I have a table that holds 2 values, starting IP and ending IP, the majority of these are ranges, not single IP's.   How can I check the single IP I get programatically against the table of IP ranges to authenticate a user?
ASKER CERTIFIED SOLUTION
Avatar of jmwheeler
jmwheeler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flukester
flukester

ASKER

Thanks jmw, seems to be working so far. Can you enlighten me to what the CompareTo() method is actually doing? How is it finding an IP if it's in a range.
CompareTo is a comparison method for objects that implement IComparable.  It returns less than zero if the instance is less than the passed obj, 0 if they are the same and greater than zero if the instance is greater than the passed obj.

http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx
Thanks a lot!