#!/usr/local/bin/perl
#
# extprog



while (<>)
{
    chomp;

    if ($_ =~ /^\s*([^\s=]+)\s*=\s*"((\\"|[^"])*)"/)
    {
	# Quoted value
	$input{$1} = $2;
    }
    elsif ($_ =~ /^([^\s=]+)\s*=\s*(.*)/)
    {
	# Unquoted value
	$input{$1} = $2;
    }
}
	#What is in User-Password? (for testing)
	print $input{'User-Password'};
	

# Reference to Name-Server
use Win32::OLE;

	$ns = Win32::OLE->new('ILDBAPI.LearnLincDB.1') ||
		die "Could not create a new Session: $!";

	if ($ns->ConnectToServer("195.126.10.202", 11721, 0))
	{
		print "Connected";

		# Function 'ValidatePassword' checks Login-inputs
		# 0 = Accept
		# 1 = Reject
		if ($ns->ValidatePassword("persona.".$input{'User-Name'}, $input{'User-Password'}, 0))
		{
	       		print "true";
			exit 0;
        	}  
		else
		{
        		print "false";
			exit 1;
        	}
	}
	else
	{
        	print "Not Connected";
   	}

        
        
