2 Replies Latest reply on Jan 15, 2008 7:29 AM by Mr Black

    Intranet Login Using Remote Address

    JeremysDad Level 1
      I am using CF6.1 on Windows Web Server 2003. I need something using the following logic. It just does not work and I can't figure out what will.


      I am getting an error because the IP address is not a number. Is there a way to do between or something?

      Thank you in advance for your help.

      David Moore
        • 1. Re: Intranet Login Using Remote Address
          Level 7
          Two ideas.

          You could treat the IP's as strings:
          <cfif CGI.Remote_ADDR GTE '' ...>


          You could treat the IP's as lists:
          <cfif listGetAt(CGI.REMOTE_ADDR,1,'.') EQ 255 AND
          listGetAt(CGI.REMOTE_ADDR,2,'.') EQ 255 AND
          listGetAt(CGI.REMOTE_ADDR,3,'.') EQ 255 AND
          listGetAt(CGI.REMOTE_ADDR,4,'.') GTE 0 AND
          listGetAt(CGI.REMOTE_ADDR,4,'.') LTE 255 AND
          listGetAt(CGI.REMOTE_ADDR,4,'.') NEQ 1>
          • 2. Re: Intranet Login Using Remote Address
            Mr Black Level 1
            IP address is (by definition) a 32-bit number. So, convert it to a number first:

            <cfset ip=ListToArray(ip, ".")>
            <cfset ip=ip[4] + 256*ip[3] + 256*256*ip[2]>

            You do not need to use the first group, because all your intranet addresses have the same number there. Now, just compare numbers in a normal fasion.