[horde] Some questions

Nicolas Fo nicolasfo at ymail.com
Wed Dec 19 16:03:40 UTC 2012




	

	

	

	



Le 19/12/2012 12:55, Jan Schneider a écrit :
>
> Zitat von Nicolas Fo <nicolasfo at ymail.com>:
>
>> Le 18/12/2012 15:26, Jan Schneider a écrit :
>>>
>>> Zitat von Nicolas Fo <nicolasfo at ymail.com>:
>>>
>>>> Le 14/12/2012 15:39, Nicolas Fo a écrit :
>>>>> Le 14/12/2012 15:00, Nicolas Fo a écrit :
>>>>>> Le 14/12/2012 14:47, Nicolas Fo a écrit :
>>>>>>> Le 28/11/2012 16:48, Oscar del Rio a écrit :
>>>>>>>> On 11/28/12 09:23 AM, Nicolas Fo wrote:
>>>>>>>>> - How to auto fill "Name" and "Surname" of a user ? Those
>>>>>>>>> informations would be stored in my AD base.
>>>>>>>>
>>>>>>>> horde/config/hooks.php  (see hooks.php.dist)
>>>>>>>>
>>>>>>>>> - How to hard setup (server side, for every users) HTML
>>>>>>>>> composing mails ?
>>>>>>>>> - How to setup IMAP folders in IMP ? What are default names
>>>>>>>>> for folders ? (Junk, sent...)
>>>>>>>>> - How to setup deleted mails go directly in trash and don't be
>>>>>>>>> crossed ?
>>>>>>>>
>>>>>>>> imp/config/prefs.local.php  (see prefs.php for all options)
>>>>>>>>
>>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> Sorry to be late, I don't have a lot of time those days..
>>>>>>>
>>>>>>> I've tried to set the FullName from my AD LDAP base in Horde
>>>>>>> (fullname is mentionned in the "cn" field)
>>>>>>>
>>>>>>> Here's my hooks.php file :
>>>>>>>
>>>>>>> <?php
>>>>>>> class Horde_Hooks
>>>>>>> {
>>>>>>>   {
>>>>>>>       switch ($pref) {
>>>>>>>       case 'fullname':
>>>>>>>
>>>>>>> //            // Example #2: Set the fullname from LDAP
>>>>>>> information. In this
>>>>>>> //            // example we look if a Spanish name exists and
>>>>>>> return this or
>>>>>>> //            // the standard 'cn' entry if not.
>>>>>>>           if (is_null($username)) {
>>>>>>>               return $value;
>>>>>>>           }
>>>>>>>
>>>>>>>           $ldapServer = 'MY.AD.SERVER';
>>>>>>>           $ldapPort = '389';
>>>>>>>           $searchBase = 'ou=OUNAME,dc=DOMAIN,DC=LOCAL';
>>>>>>>
>>>>>>>           $ds = @ldap_connect($ldapServer, $ldapPort);
>>>>>>>
>>>>>>>           $searchResult = @ldap_search($ds, $searchBase, 'uid='
>>>>>>> . $username);
>>>>>>>           $information = @ldap_get_entries($ds, $searchResult);
>>>>>>>           if (($information === false) || ($information['count']
>>>>>>> == 0)) {
>>>>>>>               $name = '';
>>>>>>>           } else {
>>>>>>>               $name = ($information[0]['cn;lang-es'][0] != '')
>>>>>>>                   ? $information[0]['cn;lang-es'][0]
>>>>>>>                   : $information[0]['cn'][0];
>>>>>>>           }
>>>>>>>
>>>>>>>           ldap_close($ds);
>>>>>>>
>>>>>>>           return empty($name)
>>>>>>>               ? $username
>>>>>>>               : $name;
>>>>>>>       }
>>>>>>>   }
>>>>>>> }
>>>>>>>
>>>>>>> I didn't understand the example with the Spanish name... So this
>>>>>>> hooks file made something wrong...lol
>>>>>>>
>>>>>>> When I try to go to login to horde, I've an error "500 Internal
>>>>>>> server error"
>>>>>>>
>>>>>>> I just want to have the user fullname set in Horde when user
>>>>>>> logs in.. No filter to apply etc..
>>>>>>>
>>>>>>> Someone to help me ? in add, i'm not sure of the selected code...
>>>>>>>
>>>>>>> Thanks :)
>>>>>> So, I changed the code to delete the "Spanish restriction" and
>>>>>> always the same problem :
>>>>>>
>>>>>> <?php
>>>>>> class Horde_Hooks
>>>>>> {
>>>>>>   {
>>>>>>       switch ($pref) {
>>>>>>       case 'fullname':
>>>>>>
>>>>>> //            // Example #2: Set the fullname from LDAP
>>>>>> information. In this
>>>>>> //            // example we look if a Spanish name exists and
>>>>>> return this or
>>>>>> //            // the standard 'cn' entry if not.
>>>>>>           if (is_null($username)) {
>>>>>>               return $value;
>>>>>>           }
>>>>>>
>>>>>>           $ldapServer = 'MY.AD.SERVER';
>>>>>>           $ldapPort = '389';
>>>>>>           $searchBase = 'ou=OUNAME,dc=DOMAIN,DC=LOCAL';
>>>>>>
>>>>>>           $ds = @ldap_connect($ldapServer, $ldapPort);
>>>>>>
>>>>>>           $searchResult = @ldap_search($ds, $searchBase, 'cn=' .
>>>>>> $username);
>>>>>>           $information = @ldap_get_entries($ds, $searchResult);
>>>>>>           if (($information === false) || ($information['count']
>>>>>> == 0)) {
>>>>>>               $name = '';
>>>>>>           }
>>>>>>           ldap_close($ds);
>>>>>>
>>>>>>           return empty($name)
>>>>>>               ? $username
>>>>>>               : $name;
>>>>>>       }
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> Thanks in advance ;)
>>>>>>
>>>>>> Nicolas
>>>>>
>>>>> I forgot this line at the begining of the file :
>>>>>
>>>>>   public function prefs_init($pref, $value, $username, $scope_ob)
>>>>>
>>>>> Now, horde login page is OK, but the username is still missing...
>>>>>
>>>>> Thanks
>>>> Hello,
>>>>
>>>> Here's my hooks.php :
>>>>
>>>> <?php
>>>> class Horde_Hooks
>>>> {
>>>>    public function prefs_init($pref, $value, $username, $scope_ob)
>>>>    {
>>>>        switch ($pref) {
>>>>        case 'fullname':
>>>>
>>>>            if (is_null($username)) {
>>>>                return $value;
>>>>            }
>>>>
>>>>            $ldapServer = 'MY.ADSERVER.LAN';
>>>>            $ldapPort = '389';
>>>>            $searchBase = 'ou=OUNAME,dc=DOMAIN,dc=lan';
>>>>
>>>>            $ds = @ldap_connect($ldapServer, $ldapPort);
>>>>
>>>>            $searchResult = @ldap_search($ds, $searchBase,
>>>> 'displayname=' . $username);
>>>>            $information = @ldap_get_entries($ds, $searchResult);
>>>>            if (($information === false) || ($information['count']
>>>> == 0)) {
>>>>                $name = '';
>>>>            }
>
> You don't use the LDAP result, at all.
>
>>>>            ldap_close($ds);
>>>>
>>>>            return empty($name)
>>>>                ? $username
>>>>                : $name;
>>>>
>>>> }
>>>> }
>>>> }
>>>>
>>>> and the prefs.local.php :
>>>>
>>>> <?php
>>>> $_prefs['fullname'] = array(
>>>>    'value' => '',
>>>>    'locked' => true,
>>>>    'shared' => true,
>>>>    'type' => 'text',
>>>>    'hook' => true,
>>>>    'desc' => _("Your full name:")
>>>> );
>>>>
>>>> It doesn't work, what am I missed ?
>>>>
>>>> Thanks
>>>
>>> "Doesn't work" isn't actually a helpful error description.
>>
>> I have my email adress between " < > " and at the left, the same
>> email address.
>>
>> By posting php pages, I hoped you could see an error..
>>
>> Thanks
>
>

" You don't use the LDAP result, at all. ", yeah, and...so ? i don't
know where I'm supposed to "use LDAP result", if it's not in the doc,
I'm not a developer...

I found a page I've never found before :
http://wiki.horde.org/CustomizingPreferences#toc7
But it seems that this page don't have been updated since the newer version.


Here's my modified hooks.php :

<?php
class Horde_Hooks
{
     public function prefs_init($pref, $value, $username, $scope_ob)
     {
         switch ($pref) {

         case 'fullname':

             if (is_null($username)) {
                 return $value;
             }

         global $conf;
         $ldapServer = 'AD.SERVER.LAN'; // (same as server used  for
LDAP authentications)
         $ldapPort = '389';
         $binddn = 'hordeuser'; // (same as user used for binding for
LDAP authentications)
         $bindpw = 'hordepasswd'; // (same as passwordused for binding
for LDAP authentications)
         $searchBase = 'OU=OUNAME,DC=DOMAIN,DC=lan'; // (same as SB used
for binding for authentications)
         $ds = ldap_connect($ldapServer, $ldapPort);
         ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
         ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

         if (ldap_bind($ds, $binddn, $bindpw)) {

             $searchResult = ldap_search($ds, $searchBase, 'cn' . '=' .
$username);
         }

         $information = @ldap_get_entries($ds, $searchResult);

             if (($information === false) || ($information['count'] == 0)) {
                 $name = '';
             }
             ldap_close($ds);

            return empty($name)
                ? $username
                : $name;
}
}
}



I'd like to have the fullname (cn in my AD base) autofilled in relation
with the login user (mail in my AD database).

I never expected that it would be so hard to have this "feature"...

Thanks in advance

Nicolas





More information about the horde mailing list