toshy62 / openldapobject
Use Object to Read/Write in a LDAP
Installs: 42
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Type:symfony-bundle
Requires
- php: >=5.4.0
- ext-ldap: *
- doctrine/annotations: ~1.0
- ulrichsg/getopt-php: 2.3.*
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: ~4
This package is not auto-updated.
Last update: 2024-03-16 14:19:52 UTC
README
Use Object to Read/Write in a LDAP
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require openldapobject/openldapobject "~1"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Or add the bundle in your composer.json
and launch this command composer update
...
"require" : {
...
"openldapobject/openldapobject": "~1.0",
...
},
...
Step 2: Configuration
Add configuration keys in the app/config/parameters.yml
and app/config/parameters.yml.dist
and configure for your openldap :
ldap_hostname: ldap-test.univ.fr
ldap_base_dn: 'dc=univ,dc=fr'
ldap_dn: 'cn=login,ou=ldapusers,dc=univ,dc=fr'
ldap_password: 'password'
Step 3: Use the Bundle
You can use this bundle like this :
<?php namespace AppBundle\Controller; use OpenLdapObject\LdapClient\Connection; use OpenLdapObject\LdapClient\Client; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class DefaultController extends Controller { /** * @Route("/example", name="example") */ public function exampleAction() { $ldap = new Connection($this->container->getParameter('ldap_hostname'), 389); $ldap->identify($this->container->getParameter('ldap_dn'), $this->container->getParameter('ldap_password')); $client = $ldap->connect(); $client->setBaseDn($this->container->getParameter('ldap_base_dn')); $query = "(&(objectclass=*)(sn=Hetru))"; $accounts = $client->search($query, array('*', 'memberof'), 0, 'ou=accounts'); dump($accounts); ... } } ... ...