Commit 9f0cf3ea authored by David Surville's avatar David Surville
Browse files

Merge branch 'zf-3.0'

parents 617a8566 84b1adb6
Loading
Loading
Loading
Loading

CHANGELOG.md

0 → 100644
+23 −0
Original line number Diff line number Diff line
CHANGELOG
=========

3.0.0 (01/10/2020)
------------------

- Adaptation du code pour le passage à ZF3.
- Scission des classes liées aux entités ("Generic", "Group", "People", "Root", "Structure" et "System") en deux classes :
    - classe de base avec un setter pour (presque) chaque attribut Ldap
    - classe qui hérite de la classe de base avec des fonctions spécifiques à l'entité
- Gestions des attributs "supannActivite", "ucbnSecteurDisciplinaire" et "supannEmpCorps"
- Ajout des getters pour les attributs de la classe "People" : "rid", "sambaSID", "uidNumber", "gidNumber", "loginShell" et "homeDirectory"
- Ajout des setters pour les différents attributs liés aux structures de la classe "People"
- Ajout des attributs cachés "createTimestamp" et "modifyTimestamp" comme DateTimeAttributes
- Ajout des setters pour les attributs de la classe "People" : "supannEtablissement", "supannEtuAnneeInscription", "supannEtuCursusAnnee", "supannEtuDiplome" et "supannEtuEtape"
- Ajout des setters pour les attributs de la classe "People" : "supannEtuInscription", "ucbnSiteLocalisation", "ucbnAnneePostBac", "ucbnCodeEtape", "ucbnEtuComplementInscription", 
"ucbnPrivateAddress", "ucbnPrivateAddresseBis", "supannEtuElementPedagogique", "supannEtuRegimeInscription", "supannEtuSecteurDisciplinaire" 
et "supannEtuTypeDiplome"
- Gestion de la modification de l'attribut "supannRefId" par étiquette
- Ajout de fonctions de vérification du statut d'une personne dans la classe "People"
- Fonction de récupération de champs date au format Php DateTime
- Mise en place d'une entité "Root" pour gérer la racine de l'annuaire Ldap et d'un service associé
- Ajout des setters pour les attributs de la classe "People" : "supannAutreMail" et "mailForwardingAddress"

README.md

0 → 100644
+42 −0
Original line number Diff line number Diff line
# UnicaenLdap

 * [Introduction](#introduction)
 * [Installation](#installation)
 * [Configuration](#configuration)
 
## Introduction
 
Ce module permet de se connecter à l'annuaire Ldap de l'université et de consulter/modifier ses données. 

## Pré-requis

L'utilisation de ce module nécessite l'installation de l'extension `ext-ldap` de PHP.

## Installation

```bash 
$ composer require unicaen/ldap
```

## Configuration

> Récupérer les fichiers de config du module 
 
```bash
$ cp -n vendor/unicaen/zimbra/config/unicaen-ldap.local.php.dist config/autoload/unicaen-ldap.local.php
```

> Adapter le contenu à vos besoins en configurant notamment les paramètres de connexion au serveur Ldap.

```php
'unicaen-ldap' => [
    'host'                => 'ldap-test.unicaen.fr',
    'port'                => 389,
    'version'             => 3,
    'baseDn'              => "dc=unicaen,dc=fr", // racine de l'annuaire
    'bindRequiresDn'      => true,
    'username'            => "uid=xxxx,ou=system,dc=unicaen,dc=fr",
    'password'            => "xxxx",
    'accountFilterFormat' => "(&(objectClass=supannPerson)(supannAliasLogin=%s))",
]
```
 No newline at end of file
+33 −29
Original line number Diff line number Diff line
@@ -14,14 +14,14 @@ use UnicaenLdap\Service\Group as LdapGroupService;
use UnicaenLdap\Service\GroupFactory as GroupServiceFactory;
use UnicaenLdap\Service\People as LdapPeopleService;
use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory;
use UnicaenLdap\Service\Root as LdapRootService;
use UnicaenLdap\Service\RootFactory as RootServiceFactory;
use UnicaenLdap\Service\Structure as LdapStructureService;
use UnicaenLdap\Service\StructureFactory as StructureServiceFactory;
use UnicaenLdap\Service\System as LdapSystemService;
use UnicaenLdap\Service\SystemFactory as SystemServiceFactory;
use Zend\ServiceManager\Proxy\LazyServiceFactory;

;;

return array(
    'unicaen-ldap' => [

@@ -30,10 +30,10 @@ return array(
        'factories' => [
            'Ldap'                      => LdapFactory::class,
            'LdapOptions'               => ModuleOptionsFactory::class,

            'LdapServiceGeneric'        => GenericServiceFactory::class,
            'LdapServiceGroup'          => GroupServiceFactory::class,
            'LdapServicePeople'         => PeopleServiceFactory::class,
            'LdapServiceRoot'           => RootServiceFactory::class,
            'LdapServiceStructure'      => StructureServiceFactory::class,
            'LdapServiceSystem'         => SystemServiceFactory::class,
        ],
@@ -43,11 +43,13 @@ return array(
            'ldapServiceGeneric'        => 'LdapServiceGeneric',
            'ldapServiceGroup'          => 'LdapServiceGroup',
            'ldapServicePeople'         => 'LdapServicePeople',
            'ldapServiceRoot'           => 'LdapServiceRoot',
            'ldapServiceStructure'      => 'LdapServiceStructure',
            'ldapServiceSystem'         => 'LdapServiceSystem',
            LdapGenericService::class   => 'LdapServiceGeneric',
            LdapPeopleService::class           =>  'LdapServicePeople',
            LdapGroupService ::class    => 'LdapServiceGroup',
            LdapPeopleService::class    => 'LdapServicePeople',
            LdapRootService::class      => 'LdapServiceRoot',
            LdapStructureService::class => 'LdapServiceStructure',
            LdapSystemService::class    => 'LdapServiceSystem',
        ],
@@ -57,6 +59,7 @@ return array(
                'LdapServicePeople'     => LdapPeopleService::class,
                'LdapServiceGeneric'    => LdapGenericService::class,
                'LdapServiceGroup'      => LdapGroupService::class,
                'LdapServiceRoot'       => LdapRootService::class,
                'LdapServiceStructure'  => LdapStructureService::class,
                'LdapServiceSystem'     => LdapSystemService::class,
            ],
@@ -71,14 +74,15 @@ return array(
            'LdapServiceGroup' => [
                LazyServiceFactory::class,
            ],
            'LdapServiceRoot' => [
                LazyServiceFactory::class,
            ],
            'LdapServiceStructure' => [
                LazyServiceFactory::class,
            ],
            'LdapServiceSystem' => [
                LazyServiceFactory::class,
            ],

        ],

    ],
);
+12 −12
Original line number Diff line number Diff line
<?php

return array(
   'unicaen-ldap' => array(
return [
    'unicaen-ldap' => [
        'host'                => 'host.domain.fr',
        'port'                => 389,
        'version'             => 3,
         'baseDn'              => "ou=xxxxxxxxxxx,dc=domain,dc=fr",
        'baseDn'              => "dc=domain,dc=fr", // racine de l'annuaire
        'bindRequiresDn'      => true,
        'username'            => "uid=xxxxxxxxx,ou=xxxxxxxxxx,dc=domain,dc=fr",
        'password'            => "xxxxxxxxxxxx",
        'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))",
     )
);
    ]
];
+189 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenLdap\Entity\Base;

use UnicaenLdap\Entity\Entity;
use UnicaenLdap\Exception;
use Zend\Ldap\Attribute;
use Zend\Ldap\Exception\LdapException;

/**
 * Classe mère des entités de la branche "generic" de l'annuaire LDAP.
 *
 * @author David Surville <david.surville@unicaen.fr>
 */
class Generic extends Entity
{
    /**
     * @var string
     */
    protected $type = 'Generic';

    /**
     * Liste des classes d'objet nécessaires à la création d'une adresse générique
     *
     * @var array
     */
    protected $objectClass = [
        'top',
        'inetOrgPerson',
        'organizationalPerson',
        'person',
    ];

    /**
     * Liste des attributs autorisés pour une entité "Generic"
     *
     * @var array
     */
    protected $authorizedAttributes = [
        // Attributes classes
        'objectClass',
        // Attributes
        'cn',
        'description',
        'mail',
        'sn',
        'supannAliasLogin',
        'ucbnServiceIMAP',
        'userPassword',
    ];


    /**
     * Liste des attributs contenant des dates
     *
     * @var string[]
     */
    protected $dateTimeAttributes = [
    ];

    /**
     * Liste des attributs monovalués
     *
     * @var array
     */
    protected $monoValuedAttributes = [
        'supannALiasLogin',
        'ucbnServiceIMAP',
        'userPassword',
    ];


    /**
     * Attribut Ldap "cn"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     */
    public function setCn($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $this->appendOrNot('cn', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "description"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     */
    public function setDescription($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $this->appendOrNot('description', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "mail"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     * @throws Exception
     * @throws LdapException
     */
    public function setMail($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $value = array_filter(filter_var_array($value, FILTER_VALIDATE_EMAIL));
        $this->appendOrNot('mail', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "sn"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     */
    public function setSn($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $this->appendOrNot('sn', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "supannALiasLogin"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     * @throws Exception
     * @throws LdapException
     */
    public function setSupannAliasLogin($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $value = array_map('strtolower', $value);
        $value = array_filter($value, function ($v) {
            return preg_match('/^[0-9a-z\-]+$/', $v);
        });

        $this->appendOrNot('supannAliasLogin', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "ucbnServiceIMAP"
     *
     * @param array|string|null $value
     * @param bool $append
     * @return self
     * @throws Exception
     * @throws LdapException
     */
    public function setUcbnServiceIMAP($value = null, $append = false)
    {
        $value = $this->preFormat($value);
        $value = array_map([$this, 'formatBoolean'], $value);
        $this->appendOrNot('ucbnServiceIMAP', $value, $append);

        return $this;
    }

    /**
     * Attribut Ldap "userPassword"
     *
     * @param string $value
     * @return self
     * @throws LdapException
     */
    public function setUserPassword(string $value)
    {
        $this->getNode()->setPasswordAttribute($value, Attribute::PASSWORD_HASH_SHA, 'userPassword');

        return $this;
    }
}
 No newline at end of file
Loading