No subject
    Oguzhan Kayhan 
    oguzhank at bilkent.edu.tr
       
    Mon Dec 24 13:56:41 CET 2007
    
    
  
Hello all,
I am trying to figure out how to use rlm_perl module for authentication
purposes.
Whats in my mind is to use my existing IMAP server to check if account
exists or not.
On the wiki page of rlm_perl i see an example script as :
# Function to handle accounting
sub accounting {
       # For debugging purposes only
#       &log_request_attributes;
       # You can call another subroutine from here
       &test_call;
       return RLM_MODULE_OK;
}
Ok...
Now.. what should be my return value for test_call subroutine to make it
work. I am planning to call an Imap module here and as a return value i
should return what?
Im not good at perl so, any tiny help will be appreciated.
I am planning to make smthing like this but i am really not sure if it
works or not:
sub imapLogin {
   my $host = shift;
   my $account = shift;
   my $password = shift;
   my $server = shift;
   # open a connection to the IMAP server
   if (! ($server = new Net::IMAP::Simple($host))) {
      return "cannot connect IMAP server";
   }
   # login, if success return 1 (true?) and 0 (false?)
   if ($server->login( $account, $password )) {
      return RLM_MODULE_OK;
   } else {
      return RLM_MODULE_REJECT;
   }
}
    
    
More information about the Freeradius-Users
mailing list