
    #Get username given IP number

	# Check acp_dialup file, which contains IP numbers and usernames for
    # users with static IP numbers

	open(IN_DIALUP,"/usr/annex/acp_dialup");
	while(<IN_DIALUP>) {
		if (/^#/) {next;}
		if (/$ipadd\D/) { 
			($login) = /(^\w*\s)/;
			chop $login;
			last;
		}	
	}
	close(IN_DIALUP);


	# If we didn't find one there, finger the terminal server to check the
	# port for dynamic-IP custimers.

	if ($login eq '') {
		$host = $ENV{'REMOTE_HOST'};

                if ($host =~ s/^ulster//) {
                	$ts="ulster.mhv.net";
                } else {
		  if ($host =~ s/^fishkill//) {
                    $ts="fishkill.mhv.net";
                  } else {
		    if ($host =~ s/^westchester//)  {
                      $ts="westchester.mhv.net";
                    } else {
		      if ($host =~ s/^orange//) {
                        $ts="orange.mhv.net";
                      } else {
			$ts="annex1.mhv.net";
                        }
                      }
                    }
                  }
		open (IN_DIALUP,"finger \@$ts |");
		while (<IN_DIALUP>) {
                        $id = substr($_,64,11);
                        if (substr($id,10,1) eq ' ') {
                             $id = substr($id,0,10);
                        }
			if ($id eq $ipadd) {
				$login = substr($_,10,8);
				$login =~ s/ |\t//g;
				last;
			}
		}
	      	close IN_DIALUP;
                if ($login eq '') {
                	$ts="annex.mhv.net";
                 	open (IN_DIALUP,"finger \@$ts |");
                 	while (<IN_DIALUP>) {
	                       $id = substr($_,64,11);
      		               if (substr($id,11,1) lt '1' || substr($id,11,1) gt '0') {
                         	  $id = substr($id,0,10);
                        	}

                        	if ($id eq $ipadd) {
                                	$login = substr($_,10,8);
                                	$login =~ s/ |\t//g;
                                	last;
                        	}
                 	}

		close IN_DIALUP;
		}
	}
	# If you need to rewrite this routine for you own terminal server, at
	# this point $login should contain the login name of the user in 
	# question.

	@info = getpwnam($login);
	$i = index($info[6],' ');
	$fname = substr($info[6],0,$i);

1;
