[dev] Newbie
    Chuck Hagenbuch 
    chuck at horde.org
       
    Sun Apr 30 14:21:46 PDT 2006
    
    
  
Quoting Raphael Melo de Oliveira Bastos Sales <raphael.melo21 at gmail.com>:
> I understand. And I do intend to do this. But I think that designing
> the API is a good way to start.
I guess my reaction to that is that you need to have a sense of what  
you want the API to _do_ before you design it. A general LDAP  
administration tool is a different beast than an API intended for use  
in writing LDAP drivers for other applications.
> As promised, the interface I was thinking. I'm hoping to increase it
> as I get a better understanding the necessities of other Horde
> developers:
>
> <?php
> class HordeLDAPDriver{
>
>     function HordeLDAPDriver( $ldap_host, $base_dn, $user = "",   
> $password ="" ){
>         /* Do LDAP connection and binds stuff here.
>          * If user and password are not set, tries anonymous bind */
>     }
You should avoid doing connection stuff in the constructor - it makes  
error handling difficult in PHP 4. If it was just PHP 5 code, you  
could throw an exception. But until we go PHP 5-only, you need to use  
an initialize() or similar function to do things that can fail.
>     function authenticateUser( $user, $password ){
>         /* Tries to authenticate an user that is in one of the
> assigned groups */
>     }
>
>     function authenticateUserByGroup( $user, $password, $groups ){
>         /* Tries to authenticate an user that is in one of the
> assigned groups */
>     }
Any reason not to have $group as an optional argument to the first  
method instead of having two methods? And how are these user/password  
variables different from the ones provided in the constructor?
Looks like an okay start to me. But I'm not an LDAP expert. :)
-chuck
-- 
"we are plastered to the windshield of the bus that is time." - Chris
    
    
More information about the dev
mailing list