users
[ class tree: users ] [ index: users ] [ all elements ]

Source for file auth.php

Documentation is available at auth.php

  1. <?php
  2. /**
  3.  * $Header$
  4.  *
  5.  * @package users
  6.  */
  7.  
  8. /**
  9.  * Class that manages the imap autentication method
  10.  *
  11.  * @package users
  12.  * @subpackage auth
  13.  */
  14. class IMAPAuth extends BaseAuth {
  15.  
  16.     function IMAPAuth({
  17.         parent::__construct('imap');
  18.     }
  19.  
  20.     function validate($user,$pass,$challenge,$response{
  21.         parent::validate($user,$pass,$challenge,$response);
  22.         $mailbox '{' $this->mConfig['server'];
  23.         if ($this->mConfig["ssl"]{
  24.             $mailbox .= "/ssl";
  25.             if ($this->mConfig["sslvalidate"]{
  26.                 $mailbox .= "/validate-cert";
  27.             else {
  28.                 $mailbox .= "/novalidate-cert";
  29.             }
  30.         }
  31.         $mailbox .= ':'.$this->mConfig["port"].'}INBOX';
  32.  
  33.         $imapauth @imap_open($mailbox,$user $pass);
  34.         if (!$imapauth{
  35.             $this->mErrors['login']=imap_errors();
  36.             $ret=USER_NOT_FOUND;
  37.         else {
  38.             $ret=USER_VALID;
  39.             $this->mInfo["real_name"$user;
  40.             if(empty($this->mConfig["email"])) {
  41.                 $this->mInfo["email"$user;
  42.             else {
  43.                 $info=array('login'=>$user);
  44.                 $replace_func create_function('$matches','$info = '.var_export($info,true).';
  45.                             $m = $matches[0];
  46.                             $m = substr($m,1,strlen($m)-2);
  47.                             if(empty($info[$m])) return "";
  48.                             return strtolower($info[$m]);');
  49.                 $this->mInfo["email"preg_replace_callback('/%.*?%/',$replace_func,$this->mConfig["email"]);
  50.             }
  51.             imap_close($imapauth);
  52.         }
  53.         return $ret;
  54.     }
  55.  
  56.     function isSupported({
  57.         $ret true;
  58.         if (!function_exists('imap_open')) {
  59.             $this->mErrors['support']=tra("IMAP Authentication is not supported as PHP IMAP Extention not loaded.");
  60.             $ret false;
  61.         }
  62.         return $ret;
  63.     }
  64.  
  65.     function createUser(&$userattr{
  66.         $this->mErrors['create']=tra("Cannot create users in an IMAP Server.");
  67.         return false;
  68.     }
  69.  
  70.     function canManageAuth({
  71.         $this->mErrors[]=tra("Cannot create users in an IMAP Server.");
  72.         return false;
  73.     }
  74.  
  75.     function getSettings({
  76.         return array(
  77.         'users_imap_server' => array(
  78.             'label' => "IMAP Server",
  79.             'type' => "text",
  80.             'note' => "",
  81.             'default' => '',
  82.         ),
  83.         'users_imap_ssl' => array(
  84.             'label' => "Connect Using SSL",
  85.             'type' => "checkbox",
  86.             'note' => "",
  87.             'default' => 'y',
  88.         ),
  89.         'users_imap_sslvalidate' => array(
  90.             'label' => "Require SSL Certificate to be valid",
  91.             'type' => "checkbox",
  92.             'note' => "",
  93.             'default' => 'n',
  94.         ),
  95.         'users_imap_port' => array(
  96.             'label' => "IMAP Port",
  97.             'type' => "text",
  98.             'note' => "",
  99.             'default' => '993',
  100.         ),
  101.         'users_imap_email' => array(
  102.             'label' => "LDAP User E-Mail Address",
  103.             'type' => "text",
  104.             'note' => "If empty the login is used.<br />Otherwise all %login% is replaced with the login name, and the result used as the email address.<br />Please remember to include the @ sign",
  105.             'default' => "%login%@redhat.com",
  106.         ),
  107.     );
  108.     }
  109. }

Documentation generated on Wed, 29 Jul 2015 13:55:35 +0000 by phpDocumentor 1.5.0-lsces