PHP code example of appserver-io / ldap

1. Go to this page and download the library: Download appserver-io/ldap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

appserver-io / ldap example snippets



/**
 * TechDivision\Project\Repositories\Ldap\RoleRepositoryInterface
 */

namespace AppserverIo\MyProject;

/**
 * Dummy implementation of a LDAP repository.
 */
class DummyRepository
{

    /**
     * The Symfony LDAP adapter instance.
     *
     * @var \AppserverIo\Appserver\PersistenceContainer\Doctrine\DoctrineEntityManagerProxy
     * @EPB\PersistenceUnit(unitName="MyLdapEntityManager")
     */
    protected $ldapEntityManager;
}


/**
 * AppserverIo\Ldap\EntityManagerInterface
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * PHP version 5
 *
 * @author    Tim Wagner <[email protected]>
 * @copyright 2015 TechDivision GmbH <[email protected]>
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      https://github.com/appserver-io/ldap
 * @link      http://www.appserver.io
 */

namespace AppserverIo\Ldap;

/**
 * The interface for all LDAP Entity Manager implementations.
 *
 * @author    Tim Wagner <[email protected]>
 * @copyright 2015 TechDivision GmbH <[email protected]>
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      https://github.com/appserver-io/ldap
 * @link      http://www.appserver.io
 */
interface EntityManagerInterface
{

    /**
     * Returns the LDAP client instance.
     *
     * @return \AppserverIo\Ldap\LdapClientInterface The LDAP client instance
     */
    public function getLdapClient();

    /**
     * Returns the persistence unit configuration instance.
     *
     * @return \AppserverIo\Description\Configuration\PersistenceUnitConfigurationInterface The configuration instance
     */
    public function getConfiguration();

    /**
     * Returns the base DN => database in datasource configuration.
     *
     * @return string The base DN
     */
    public function getBaseDn();

    /**
     * Returns the repository instance for the entity with the passed lookup name.
     *
     * @param string $lookupName The lookup name of the entity to return the repository for
     *
     * @return object The LDAP repository instance
     */
    public function getRepository($lookupName);

    /**
     * Finds an entity by its lookup name.
     *
     * @param string $lookupName The look name of the entity to find
     * @param mixed  $id         The identity of the entity to find
     *
     * @return object|null The entity instance or NULL if the entity can not be found.
     *
     * @throws \Exception
     */
    public function find($lookupName, $id);

    /**
     * Tells the EntityManager to make an instance managed and persistent.
     *
     * The entity will be entered into the database at or before transaction
     * commit or as a result of the flush operation.
     *
     * NOTE: The persist operation always considers entities that are not yet known to
     * this EntityManager as NEW. Do not pass detached entities to the persist operation.
     *
     * @param object $entity The instance to make managed and persistent
     *
     * @return void
     * @throws \Exception
     */
    public function persist($entity);

    /**
     * Removes an entity instance.
     *
     * A removed entity will be removed from the database at or before transaction commit
     * or as a result of the flush operation.
     *
     * @param object $entity The entity instance to remove
     *
     * @return void
     * @throws \Exception
     */
    public function remove($entity);