[commits] [Wiki] created: LDAPHooksHorde5

Wiki Guest wikiguest at horde.org
Sun Feb 17 09:37:19 UTC 2013


guest [59.167.157.243]  Sun, 17 Feb 2013 09:37:19 +0000

Created page: http://wiki.horde.org/LDAPHooksHorde5



<?php
class Horde_Hooks
{
     public function prefs_init($pref, $value, $username, $scope_ob)
     {
         switch ($pref) {
         case 'from_addr':
             if (is_null($username)) {
                 return $value;
             }
             $searchBase = 'ou=users,dc=simonandkate,dc=lan';
             $cmd = '/usr/bin/ldapsearch -ZZ -x -b ' . $searchBase . '  
uid=' . escapeshellcmd($username) . ' | /bin/grep mail | /usr/bin/awk  
\'{print $2}\'';
	     $mails = `$cmd`;
             $mail_array = explode("\n", $mails);
             $mail = $mail_array['0'];
             return empty($mail)
                 ? ''
                 : $mail;

         case 'fullname':
             if (is_null($username)) {
                 return $value;
             }
		$searchBase = 'ou=users,dc=simonandkate,dc=lan';
		$cmd = '/usr/bin/ldapsearch -ZZ -x -b ' . $searchBase . ' uid=' .  
escapeshellcmd($username) . ' | /bin/grep cn: | /usr/bin/cut -c5-';
		$cns = `$cmd`;
		$cn_array = explode("\n", $cns);
		$cn = $cn_array['0'];
		return empty($cn)
			? $username
			: $cn;
         }
     }
}




More information about the commits mailing list