[Evolvis-commits] r103: yank out the old, broken/hackish, LDAP support↵

mirabilos at evolvis.org mirabilos at evolvis.org
Fri Feb 20 15:30:13 CET 2009


Author: mirabilos
Date: 2009-02-20 14:30:13 +0000 (Fri, 20 Feb 2009)
New Revision: 103

Removed:
   branches/php-v5-sid-branch/www/account/ldap_user.class
Modified:
   branches/php-v5-sid-branch/README.evolvis
   branches/php-v5-sid-branch/www/account/change_email-complete.php
   branches/php-v5-sid-branch/www/account/change_pw.php
   branches/php-v5-sid-branch/www/account/index.php
Log:
yank out the old, broken/hackish, LDAP support


Modified: branches/php-v5-sid-branch/README.evolvis
===================================================================
--- branches/php-v5-sid-branch/README.evolvis	2009-02-20 14:22:58 UTC (rev 102)
+++ branches/php-v5-sid-branch/README.evolvis	2009-02-20 14:30:13 UTC (rev 103)
@@ -3,10 +3,8 @@
 • see “GForge(base) php5” for initial setup instructions of the
   o̲l̲d̲ PHP5 branch, which is similar to this one but Etch-based,
   not sid-based
-• see “Ldap” too, this one seems to require an LDAP server running
-  ⇒ will n̲o̲t̲ work in a chroot i̲f̲ a slapd is already running on the
-    host system outside of the chroot
 • “Evolvis Roadmap” is where we eventually want to go
+• This is Evolvis, not FusionForge or GForge!
 
 ───────────────────────────────────────────────────────
 $Id$


Property changes on: branches/php-v5-sid-branch/README.evolvis
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: branches/php-v5-sid-branch/www/account/change_email-complete.php
===================================================================
--- branches/php-v5-sid-branch/www/account/change_email-complete.php	2009-02-20 14:22:58 UTC (rev 102)
+++ branches/php-v5-sid-branch/www/account/change_email-complete.php	2009-02-20 14:30:13 UTC (rev 103)
@@ -28,7 +28,6 @@
 require_once('../env.inc.php');
 require_once $gfwww.'include/pre.php';    
 require_once $gfcommon.'include/account.php';
-require_once('ldap_user.class');
 
 $confirm_hash = getStringFromRequest('confirm_hash');
 
@@ -67,11 +66,6 @@
 		plugin_hook('change_cal_mail',user_getid());
 	}
 
-//extension change email in LDAP as well, since it would get overwritten otherwise
-$ldap=new ldap_user(db_result($res_user, 0, 'user_name'));
-$ldap_new['mail']=$u->getNewEmail();
-$ldap->edit_user($ldap_new);
-
 site_user_header(array('title'=>_('Email Change Complete')));
 ?>
 

Modified: branches/php-v5-sid-branch/www/account/change_pw.php
===================================================================
--- branches/php-v5-sid-branch/www/account/change_pw.php	2009-02-20 14:22:58 UTC (rev 102)
+++ branches/php-v5-sid-branch/www/account/change_pw.php	2009-02-20 14:30:13 UTC (rev 103)
@@ -26,7 +26,6 @@
 require_once('../env.inc.php');
 require_once $gfwww.'include/pre.php';
 require_once $gfcommon.'include/account.php';
-require_once('ldap_user.class');
 
 session_require(array('isloggedin'=>1));
 
@@ -80,12 +79,6 @@
 	//plugin webcal change user password
 	else {
 		plugin_hook('change_cal_password',user_getid());
-		//change in LDAP too
-		$res = pg_query("SELECT user_name FROM users WHERE id='".user_getid()."'");
-		$row = db_fetch_array($res);
-		$ldap=new ldap_user($row['user_name']);
-		$ldap_new['userPassword']='{crypt}'.crypt($passwd);
-		$ldap->edit_user($ldap_new);
 	}
 
 	site_user_header(array('title'=>_('Successfully Changed Password')));

Modified: branches/php-v5-sid-branch/www/account/index.php
===================================================================
--- branches/php-v5-sid-branch/www/account/index.php	2009-02-20 14:22:58 UTC (rev 102)
+++ branches/php-v5-sid-branch/www/account/index.php	2009-02-20 14:30:13 UTC (rev 103)
@@ -26,19 +26,7 @@
 require_once('../env.inc.php');
 require_once $gfwww.'include/pre.php';
 require_once $gfcommon.'include/timezones.php';
-require_once('ldap_user.class');
 
-// WTF does this do?
-$conn = pg_connect ("host=evolvis-test  port=5432
-                     dbname=gforge user=richard 
-                     password=richard"
-                   );
-$db = pg_dbname ($conn);
-$u_db_sql = "SELECT * FROM users WHERE user_id = '".user_getid()."'";
-$res =  pg_query($u_db_sql);
-$u_db = db_fetch_array($res);
-$u_ldap = new ldap_user($u_db['user_name']);
-
 if (!session_loggedin()) {
 	exit_not_logged_in();
 }
@@ -52,64 +40,55 @@
 }
 
 if (getStringFromRequest('submit')) {
-	if (pg_num_rows($res)==1 AND $u_ldap->select_user()!=array('count'=>0)) {
-		if (!form_key_is_valid(getStringFromRequest('form_key'))) {
-			exit_form_double_submit();
-		}
+	if (!form_key_is_valid(getStringFromRequest('form_key'))) {
+		exit_form_double_submit();
+	}
 
 
-		$firstname = getStringFromRequest('firstname');
-		$lastname = getStringFromRequest('lastname');
-		$language = getIntFromRequest('language');
-		$timezone = getStringFromRequest('timezone');
-		$theme_id = getIntFromRequest('theme_id');
-		$ccode = getStringFromRequest('ccode');
-		$address = getStringFromRequest('address');
-		$address2 = getStringFromRequest('address2');
-		$phone = getStringFromRequest('phone');
-		$fax = getStringFromRequest('fax');
-		$title = getStringFromRequest('title');
-		$jabber_address = getStringFromRequest('jabber');
-		$jabber_only = getStringFromRequest('jabber');
-		$mail_site = getStringFromRequest('mail_site');
-		$mail_va = getStringFromRequest('mail_va');
-		$remember_user = getStringFromRequest('remember_user');
-		$use_ratings = getStringFromRequest('use_ratings');
+	$firstname = getStringFromRequest('firstname');
+	$lastname = getStringFromRequest('lastname');
+	$language = getIntFromRequest('language');
+	$timezone = getStringFromRequest('timezone');
+	$theme_id = getIntFromRequest('theme_id');
+	$ccode = getStringFromRequest('ccode');
+	$address = getStringFromRequest('address');
+	$address2 = getStringFromRequest('address2');
+	$phone = getStringFromRequest('phone');
+	$fax = getStringFromRequest('fax');
+	$title = getStringFromRequest('title');
+	$jabber_address = getStringFromRequest('jabber');
+	$jabber_only = getStringFromRequest('jabber');
+	$mail_site = getStringFromRequest('mail_site');
+	$mail_va = getStringFromRequest('mail_va');
+	$remember_user = getStringFromRequest('remember_user');
 
-	/*
-	//needs security audit
-		if ($remember_user) {
-			// set cookie, expire in 3 months
-			setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
-		} else {
-			// remove cookie
-			setcookie("sf_user_hash",'',0,'/');
-		}
-	*/
-		// Refresh page if language or theme changed
-		if ($language != $u_db['language'] || $theme_id != $u_db['theme_id']) {
-			$refresh = 1;
-		}
+/*
+//needs security audit
+	if ($remember_user) {
+		// set cookie, expire in 3 months
+		setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
+	} else {
+		// remove cookie
+		setcookie("sf_user_hash",'',0,'/');
+	}
+*/
+	// Refresh page if language or theme changed
+	if ($language != $u->getLanguage() || $theme_id != $u->getThemeID()) {
+		$refresh = 1;
+	}
 
-		//update sql and ldap
-		$new_ldap['sn']=$lastname;
-		$new_ldap['givenname']=$firstname;
-		$new_ldap['cn']=$firstname.' '.$lastname;
-		$u_ldap->edit_user($new_ldap);
-		if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, 0,
-			$jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)) {
-			form_release_key(getStringFromRequest('form_key'));
-			$feedback .= $u->getErrorMessage().'<br />';
-		} else {
-			$feedback .= _('Updated').'<br />';
-		}
-
-		if ($refresh) {
-			session_redirect("/account/?feedback=".urlencode($feedback));
-		}
+	if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, 0,
+		$jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)) {
+		form_release_key(getStringFromRequest('form_key'));
+		$feedback .= $u->getErrorMessage().'<br />';
 	} else {
-		echo 'Fatal Error! Unable to find user.';
+		$feedback .= _('Updated').'<br />';
 	}
+
+	if ($refresh) {
+		session_redirect("/account/?feedback=".urlencode($feedback));
+	}
+
 }
 
 site_user_header(array('title'=>_('Account Maintenance')));

Deleted: branches/php-v5-sid-branch/www/account/ldap_user.class
===================================================================
--- branches/php-v5-sid-branch/www/account/ldap_user.class	2009-02-20 14:22:58 UTC (rev 102)
+++ branches/php-v5-sid-branch/www/account/ldap_user.class	2009-02-20 14:30:13 UTC (rev 103)
@@ -1,136 +0,0 @@
-<?php
-
-// $Id$
-
-class ldap_user {
-	var $connection=false;
-	var $is_connected=false;
-	var $ldaphost = "localhost";
-	//var $dn = "dc=evolvis, dc=org";
-	var $dn = "dc=evolvis-trial, dc=tarent, dc=de";
-	//var $ldapuser="SF_robot";
-	var $ldapuser="admin";
-	//var $ldappw="C+29fyT!a";
-	var $ldappw="changeit";
-	var $user_selected=false;
-	var $userarr=array();
-	var $uname_actual='';
-
-	function ldap_user($uname='')
-	{
-		$this->change_uname($uname);
-		if(!$this->is_connected)
-			$this->connect();
-	}
-
-	function connect() //should be private
-	{
-		$this->connection=ldap_connect($this->ldaphost);
-		ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_bind($this->connection,"cn=".$this->ldapuser.", ".$this->dn, $this->ldappw);
-		$this->is_connected=true;
-	}
-
-	function change_uname($uname) //public
-	{
-		$this->uname_actual=$this->ldap_escape_string($uname);
-	}
-
-	function select_user_specialid($uname)
-	{
-		$search=ldap_search($this->connection, "ou=People, ".$this->dn, 'uid='.$uname);
-		$info = ldap_get_entries($this->connection, $search);
-		$this->userarr=$info;
-		return $this->userarr;
-	}
-
-	function select_user() //public
-	{
-		$search=ldap_search($this->connection, "ou=People, ".$this->dn, 'uid='.$this->uname_actual);
-		$info = ldap_get_entries($this->connection, $search);
-		$this->userarr=$info;
-		return $this->userarr;
-	}
-
-	function edit_user($edit=array()) //public
-	{
-		$edit['uid']=$this->uname_actual;
-		ldap_modify($this->connection,"uid=".$edit['uid'].", ou=people, ".$this->dn,$edit);
-	}
-
-	function delete_user() //public
-	{
-		ldap_delete($this->connection,"uid=".$this->uname_actual.", ou=People, ".$this->dn);
-	}
-
-	function add_user($info=array()) //public
-	{
-		if((!empty($info)) AND ($this->select_user_specialid($info['user_name'])==array('count'=>0)))
-		{
-			$item["uid"][0] = $info['user_name'];
-			$item["uid"][2] = 0; //isMitarbeiter = 0
-			$item["userpassword"] = '{crypt}'.crypt($info["userpassword"]);
-			$item["givenname"] = $info["first_name"];
-			$item["cn"] = $info["full_name"];
-			$item["sn"] = $info["last_name"];
-			$item["mail"] = $info["email"];
-			$item["loginshell"] = "/lib/anonsvnsh";
-			$item["homeDirectory"] = "/var/lib/gforge/chroot/home/users/".$info['user_name'];
-			$item["objectclass"][0]='inetOrgPerson';
-			$item["objectclass"][1]='organizationalPerson';
-			$item["objectclass"][2]='person';
-			$item["objectclass"][3]='posixAccount';
-			$item["objectclass"][4]='top';
-			$item["objectclass"][5]='shadowAccount';
-			$item["objectclass"][6]='debGforgeAccount';
- 			$item["uid"][1]=$this->get_next_id();
-			$item["gidNumber"]=$this->get_next_id('gid');
-			$item["uidNumber"]=$this->get_next_id('uid');
-			ldap_add($this->connection," uid=".$this->ldap_escape_string($info['user_name']).", ou=People, ".$this->dn,$item);
-
- 			$this->update_sql();
-			return $item["uid"][1];
-		} else
-		{
-			return false;
-		}
-	}
-
-	function get_next_id($str='user_id') //public
-	{
-		$conn = pg_connect ("host=evolvis-test  port=5432
-				dbname=gforge user=richard 
-				password=richard"
-				);
-		$db = pg_dbname ($conn);
-		
-		$sql = "SELECT user_id FROM users order by user_id DESC LIMIT 1;";
-		$res = pg_query($sql);
-		$ar['user_id']=pg_fetch_result($res,0,'user_id')+1;
-		$ar['gid']=20000+$ar['user_id'];
-		$ar['uid']=20000+$ar['user_id'];
-		return $ar[$str];
-	}
-
-	function ldap_escape_string($string) //public
-	{
-		 $string = str_replace(",", '\\,', $string);
-		 $string = str_replace('"', '\\"', $string);
-		 $string = str_replace("'", '\\\'', $string);
-		 $string = str_replace("<", '\\<', $string);
-		 $string = str_replace(">", '\\>', $string);
-		 $string = str_replace(";", '\\;', $string);
-		 $string = str_replace('\\', '\\\\', $string);
-		 $string = str_replace("+", '\\+,', $string);
-		 $string = str_replace("=", '\\=,', $string);
-		 $string = str_replace("#", '\\#', $string);
-		return $string;
-	}
-
-	function update_sql() //should be private
-	{
-		$internal=true;
-		include "../../../../../root/ldap/ldap2sql.php";
-	}
-}
-?>




More information about the evolvis-commits mailing list