/[ludap]/ludap/ludap.lib.php
ViewVC logotype

Diff of /ludap/ludap.lib.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by mose, Wed Sep 24 12:48:57 2003 UTC revision 1.24 by mose, Wed Oct 22 22:50:17 2003 UTC
# Line 178  class ludap { Line 178  class ludap {
178                  }                  }
179          }          }
180    
181            function signup_user() {
182                    $binddn = $this->conf['authbaseattr']."=".utf8_encode($this->conf["authuser"]).", ".$this->conf['authbasedn'];
183                    $bind = @ldap_bind($this->conn, $binddn, $this->conf['authpass']);
184    
185            }
186    
187  /** establish a connection to the LDAP server  /** establish a connection to the LDAP server
188   */   */
189          function auth($me, $login=false , $pass=false) {          function auth(&$me, $group=false, $login=false , $pass=false) {
190                  if (!$me) {                  if (!$me) {
191                          $this->logout();                          $this->logout();
192                  }                  }
193                                    
194            //      echo'<pre>';print_r(get_defined_vars());echo'</pre>';
195                  if (!$me && $login && $pass) {                  if (!$me && $login && $pass) {
196                          $binddn = $this->conf['baseattr']."=".utf8_encode($login).", ".$this->conf['basedn'];                          $binddn = $this->conf['baseattr']."=".utf8_encode($login).", ".$this->conf['basedn'];
197                          if (@ldap_bind($this->conn, $binddn, $pass)) {                          $bind = @ldap_bind($this->conn, $binddn, $pass);
198                            if ($bind) {
199                                  $i = ldap_search($this->conn, $this->conf['groupdn'], $this->conf['groupattr']."= $binddn", array($this->conf['membattr']));                                  $i = ldap_search($this->conn, $this->conf['groupdn'], $this->conf['groupattr']."= $binddn", array($this->conf['membattr']));
200                                  $ix  = ldap_get_entries($this->conn, $i);                                  $ix  = ldap_get_entries($this->conn, $i);
201                                  for ($x=0; $x<$ix["count"]; $x++) {                                  for ($x=0; $x<$ix["count"]; $x++) {
202                                          $gps[] = $ix["$x"]["{$this->conf['membattr']}"][0];                                          $gps[] = $ix["$x"]["{$this->conf['membattr']}"][0];
203                                  }                                  }
204                                    if (isset($gps) and is_array($gps)) {
205                                            if ($group and (!in_array($group,$gps))) {
206                                                    $this->message.= $this->conf['notinrightgroup']." ($group)";
207                                                    return false;
208                                            }
209                                            $_SESSION['gps'] = $gps;
210                                            if (is_array($gps) and in_array($this->conf['admingrp'],$gps)) {
211                                                    $this->admin = true;
212                                                    $_SESSION['admin'] = $this->admin;
213                                            }
214                                    } elseif ($group) {
215                                            $this->message.= $this->conf['notinrightgroup']." ($group)";
216                                            return false;
217                                    }
218                                  $_SESSION['me'] = $login;                                  $_SESSION['me'] = $login;
                                 session_register('pass');  
219                                  $_SESSION['pass'] = $pass;                                  $_SESSION['pass'] = $pass;
                                 $_SESSION['gps'] = $gps;  
                                 if (is_array($gps) and in_array($this->conf['admingrp'],$gps)) {  
                                         $this->admin = true;  
                                         $_SESSION['admin'] = $this->admin;  
                                 }  
220                                  $this->rawlog("Login - $login");                                  $this->rawlog("Login - $login");
221                                    $me = $login;
222                                  return true;                                  return true;
223                          } else {                          } else {
224                                  $this->message.= "<br />".$this->showerror();                                  $this->message.= "<br />".$this->showerror();
# Line 209  class ludap { Line 226  class ludap {
226                          }                          }
227                  } elseif ($me) {                  } elseif ($me) {
228                          $binddn = $this->conf['baseattr']."=".utf8_encode($me).", ".$this->conf['basedn'];                          $binddn = $this->conf['baseattr']."=".utf8_encode($me).", ".$this->conf['basedn'];
229                          if (@ldap_bind($this->conn, $binddn, $_SESSION['pass'])) {                          $bind = @ldap_bind($this->conn, $binddn, $_SESSION['pass']);
230                                  return true;                          if ($bind) {
231                                    if ((!isset($_SESSION['gps']) and $group) or (is_array($_SESSION['gps']) and $group and !in_array($group,$_SESSION['gps']))) {
232                                            $this->logout();
233                                            $this->message.= $this->conf['notinrightgroup']." ($group)";
234                                            return false;
235                                    } else {
236                                            return true;
237                                    }
238                          } else {                          } else {
239                                  return false;                                  return false;
240                          }                          }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26