adhomeDirectory

This commit is contained in:
2021-01-21 11:35:12 +01:00
parent ceeac44ede
commit f75058bc30
6 changed files with 31 additions and 6 deletions

View File

@ -6,8 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Cadoles\CoreBundle\Validator as CadolesCoreAssert;
use Symfony\Component\Validator\Constraints as Assert;
use Cadoles\CoreBundle\Validator\Password;
/**
@ -44,6 +44,7 @@ class User implements UserInterface, \Serializable
/**
* @ORM\Column(type="string", length=250)
* @CadolesCoreAssert\PasswordValidator
*/
private $password;

View File

@ -109,6 +109,7 @@ services:
- %ldap_port%
- %ldap_tls%
- %ldap_type%
- %ldap_addomaine%
calls:
- [setUser, ["%ldap_user%"]]
- [setPassword, ["%ldap_password%"]]

View File

@ -15,23 +15,27 @@ class ldapService
protected $port;
protected $tls;
protected $type;
protected $addomaine;
protected $baseDN;
protected $baseUser;
protected $baseNiveau01;
protected $baseNiveau02;
protected $baseGroup;
protected $user = null;
protected $password = null;
private $connection = null;
private $ldapSync = false;
public function __construct($host, $port, $tls, $type)
public function __construct($host, $port, $tls, $type, $addomaine)
{
$this->host = $host;
$this->port = $port;
$this->tls = $tls;
$this->type = $type;
$this->host = $host;
$this->port = $port;
$this->tls = $tls;
$this->type = $type;
$this->addomaine = $addomaine;
}
public function isEnabled() {
@ -312,6 +316,7 @@ class ldapService
$attrs['sAMAccountName'] = $user->getUsername();
$attrs["userAccountControl"] = 544;
$attrs["homeDrive"] = "U:";
$attrs["homeDirectory"] = "\\\\".$this->addomaine."\\".$user->getUsername();
}
$attrs['givenName'] = $user->getFirstname();

View File

@ -4,10 +4,15 @@ namespace Cadoles\CoreBundle\Validator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
/**
* @Annotation
*/
class PasswordValidator extends ConstraintValidator
{
public function validate($value, Constraint $constraint)
{
$this->context->addViolation($constraint->message);
if(!empty($value)) {
if (strlen($value) < '8') {
$this->context->addViolation($constraint->message);