Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    41.3. Usage Scenarios

    41.3.1. Authentication scenarios

    41.3.1.1. OpenLDAP

    41.3.1.2. ActiveDirectory

    41.3.2. Basic CRUD operations

    41.3.2.1. Retrieving data from the LDAP

    Ejemplo 41.1. Getting an entry by its DN

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $hm $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
    /*
    $hm is an array of the following structure
    array(
        'dn'          => 'cn=Hugo Müller,ou=People,dc=my,dc=local',
        'cn'          => array('Hugo Müller'),
        'sn'          => array('Müller'),
        'objectclass' => array('inetOrgPerson', 'top'),
        ...
    )
    */

    Ejemplo 41.2. Check for the existence of a given DN

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $isThere $ldap->exists('cn=Hugo Müller,ou=People,dc=my,dc=local');

    Ejemplo 41.3. Count children of a given DN

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $childrenCount $ldap->countChildren(
                                
    'cn=Hugo Müller,ou=People,dc=my,dc=local');

    Ejemplo 41.4. Searching the LDAP tree

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $result $ldap->search('(objectclass=*)',
                            
    'ou=People,dc=my,dc=local',
                            
    Zend_Ldap_Ext::SEARCH_SCOPE_ONE);
    foreach (
    $result as $item) {
        echo 
    $item["dn"] . ': ' $item['cn'][0] . PHP_EOL;
    }

    41.3.2.2. Adding data to the LDAP

    Ejemplo 41.5. Add a new entry to the LDAP

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $entry = array();
    Zend_Ldap_Attribute::setAttribute($entry'cn''Hans Meier');
    Zend_Ldap_Attribute::setAttribute($entry'sn''Meier');
    Zend_Ldap_Attribute::setAttribute($entry'objectClass''inetOrgPerson');
    $ldap->add('cn=Hans Meier,ou=People,dc=my,dc=local'$entry);

    41.3.2.3. Deleting from the LDAP

    Ejemplo 41.6. Delete an existing entry from the LDAP

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $ldap->delete('cn=Hans Meier,ou=People,dc=my,dc=local');

    41.3.2.4. Updating the LDAP

    Ejemplo 41.7. Update an existing entry on the LDAP

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $hm $ldap->getEntry('cn=Hugo Müller,ou=People,dc=my,dc=local');
    Zend_Ldap_Attribute::setAttribute($hm'mail''mueller@my.local');
    Zend_Ldap_Attribute::setPassword($hm,
                                     
    'newPa$$w0rd',
                                     
    Zend_Ldap_Attribute::PASSWORD_HASH_SHA1);
    $ldap->update('cn=Hugo Müller,ou=People,dc=my,dc=local'$hm);

    41.3.3. Extended operations

    41.3.3.1. Copy and move entries in the LDAP

    Ejemplo 41.8. Copy a LDAP entry recursively with all its descendants

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $ldap->copy('cn=Hugo Müller,ou=People,dc=my,dc=local',
                
    'cn=Hans Meier,ou=People,dc=my,dc=local',
                
    true);

    Ejemplo 41.9. Move a LDAP entry recursively with all its descendants to a different subtree

    $options = array(/* ... */);
    $ldap = new Zend_Ldap($options);
    $ldap->bind();
    $ldap->moveToSubtree('cn=Hugo Müller,ou=People,dc=my,dc=local',
                         
    'ou=Dismissed,dc=my,dc=local',
                         
    true);

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...