ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
KADM5.php
Go to the documentation of this file.
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
29require_once 'Auth/Container.php';
33require_once 'PEAR.php';
34
56
57 // {{{ properties
58
63 var $options = array();
64
65 // }}}
66 // {{{ Auth_Container_KADM5()
67
82 if (!extension_loaded('kadm5')) {
83 return PEAR::raiseError("Cannot use Kerberos V authentication, KADM5 extension not loaded!", 41, PEAR_ERROR_DIE);
84 }
85
86 $this->_setDefaults();
87
88 if (isset($options['hostname'])) {
89 $this->options['hostname'] = $options['hostname'];
90 }
91 if (isset($options['realm'])) {
92 $this->options['realm'] = $options['realm'];
93 }
94 if (isset($options['timeout'])) {
95 $this->options['timeout'] = $options['timeout'];
96 }
97 if (isset($options['checkServer'])) {
98 $this->options['checkServer'] = $options['checkServer'];
99 }
100
101 if ($this->options['checkServer']) {
102 $this->_checkServer();
103 }
104 }
105
106 // }}}
107 // {{{ fetchData()
108
116 function fetchData($username, $password) {
117 $this->log('Auth_Container_KADM5::fetchData() called.', AUTH_LOG_DEBUG);
118 if ( ($username == NULL) || ($password == NULL) ) {
119 return false;
120 }
121
122 $server = $this->options['hostname'];
123 $realm = $this->options['realm'];
124 $check = @kadm5_init_with_password($server, $realm, $username, $password);
125
126 if ($check == false) {
127 return false;
128 } else {
129 return true;
130 }
131 }
132
133 // }}}
134 // {{{ _setDefaults()
135
141 function _setDefaults() {
142 $this->options['hostname'] = 'localhost';
143 $this->options['realm'] = NULL;
144 $this->options['timeout'] = 10;
145 $this->options['checkServer'] = false;
146 }
147
148 // }}}
149 // {{{ _checkServer()
150
156 function _checkServer() {
157 $fp = @fsockopen ($this->options['hostname'], 88, $errno, $errstr, $this->options['timeout']);
158 if (is_resource($fp)) {
159 @fclose($fp);
160 } else {
161 $message = "Error connecting to Kerberos V server "
162 .$this->options['hostname'].":".$this->options['port'];
163 return PEAR::raiseError($message, 41, PEAR_ERROR_DIE);
164 }
165 }
166
167 // }}}
168
169}
170
171?>
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
const PEAR_ERROR_DIE
Definition: PEAR.php:34
_setDefaults()
Set some default options.
Definition: KADM5.php:141
Auth_Container_KADM5($options)
Constructor of the container class.
Definition: KADM5.php:81
fetchData($username, $password)
Try to login to the KADM5 server.
Definition: KADM5.php:116
_checkServer()
Check if the given server and port are reachable.
Definition: KADM5.php:156
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition: PEAR.php:524
$server