Ejemplo n.º 1
0
 /**
  * Loading User datas
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     // Creating Super Admin User
     $userSuper = new User();
     $userSuper->setUsername('sys');
     $password = $this->encoder->encodePassword($userSuper, 'sys');
     $userSuper->setPassword($password);
     $userSuper->setEmail('sys@ecosystem.v2');
     $userSuper->setDn('uid=sys,dc=ldap,dc=test');
     $userSuper->setLastName('sys');
     $userSuper->setFirstName('sys');
     $userSuper->setLanguage('en');
     $userSuper->setEnabled(true);
     $userSuper->setRoles(['ROLE_SUPER_ADMIN']);
     $manager->persist($userSuper);
     // Creating Admin user
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $password = $this->encoder->encodePassword($userAdmin, 'admin');
     $userAdmin->setPassword($password);
     $userAdmin->setEmail('admin@ecosystem.v2');
     $userAdmin->setDn('uid=admin,dc=ldap,dc=test');
     $userAdmin->setLastName('admin');
     $userAdmin->setFirstName('admin');
     $userAdmin->setLanguage('en');
     $userAdmin->setEnabled(true);
     $userAdmin->setRoles(['ROLE_ADMIN']);
     $manager->persist($userAdmin);
     // Flushing datas
     $manager->flush();
 }
Ejemplo n.º 2
0
 /**
  * Adding new LDAP User to database
  * @param $userArray
  * @return User
  */
 protected function processDBUserRegister($userArray)
 {
     // Creating DB User object
     $dbUser = new User();
     $dbUser->setUsername($userArray['uid']);
     // Setting empty password
     $dbUser->setPassword('');
     $dbUser->setEmail($userArray['mail']);
     $dbUser->setDn($userArray['userDn']);
     $dbUser->setLastName($userArray['sn']);
     $dbUser->setFirstName($userArray['givenName']);
     $dbUser->setLanguage($userArray['preferredLanguage']);
     $dbUser->setEnabled(true);
     $dbUser->setRoles(['ROLE_USER']);
     // Adding it to database
     $this->em->persist($dbUser);
     $this->em->flush();
     return $dbUser;
 }