Exemplo n.º 1
0
 /**
  * @Route("/group/{platformid}/{organizationid}/new", name="_group_new", requirements={
  *    "platformid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *    "organizationid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  * })
  */
 public function newAction(Request $request, $platformid, $organizationid)
 {
     $platform_repository = (new PlatformPeer())->getLdapManager()->getRepository('platform');
     $platform = $platform_repository->getPlatformByUUID($platformid);
     $organizationPeer = new OrganizationPeer($platform->getDn());
     $organization_repository = $organizationPeer->getLdapManager()->getRepository('organization');
     $organization = $organization_repository->getOrganizationByUUID($organizationid);
     $domainPeer = new DomainPeer($organization->getDn());
     $domain_repository = $domainPeer->getLdapManager()->getRepository('domain');
     $userPeer = new UserPeer($organization->getDn());
     $user_repository = $userPeer->getLdapManager()->getRepository('user');
     $group = new Group();
     $group->setZacaciastatus("enable");
     $group->setPlatformId($platform->getEntryUUID());
     $group->setOrganizationId($organization->getEntryUUID());
     $form = $this->createForm(GroupType::class, $group, array('domain_choices' => $domain_repository->getAllDomainsAsChoice(), 'member_choices' => $user_repository->getAllUsersAsChoice()));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $groupPeer = new GroupPeer($organization->getDn());
             $group->setEmail(sprintf('%s@%s', $group->getEmail(), $group->getDomain()));
             $groupPeer->createGroup($group);
             return $this->redirectToRoute('_group', array('platformid' => $platform->getEntryUUID(), 'organizationid' => $organization->getEntryUUID()));
         } catch (LdapConnectionException $e) {
             echo "Failed to add group!" . PHP_EOL;
             echo $e->getMessage() . PHP_EOL;
         }
     }
     return $this->render('ZacaciaBundle:Group:new.html.twig', array('platform' => $platform, 'organization' => $organization, 'form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * @Route("/user/{platformid}/{organizationid}/{userid}/delete", name="_user_delete", requirements={
  *     "platformid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *     "organizationid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *     "userid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})"
  * })
  */
 public function deleteAction(Request $request, $platformid, $organizationid, $userid)
 {
     $platform_repository = (new PlatformPeer())->getLdapManager()->getRepository('platform');
     $platform = $platform_repository->getPlatformByUUID($platformid);
     $organizationPeer = new OrganizationPeer($platform->getDn());
     $organization_repository = $organizationPeer->getLdapManager()->getRepository('organization');
     $organization = $organization_repository->getOrganizationByUUID($organizationid);
     try {
         $userPeer = new UserPeer($organization->getDn());
         $userPeer->deleteUser($userid, true);
     } catch (LdapConnectionException $e) {
         echo "Failed to delete user!" . PHP_EOL;
         echo $e->getMessage() . PHP_EOL;
     }
     return $this->redirectToRoute('_user', array('platformid' => $platform->getEntryUUID(), 'organizationid' => $organization->getEntryUUID()));
 }
Exemplo n.º 3
0
 /**
  * @Route("/check/edituseremail/{userid}/{email}", name="_check_edituseremail", requirements={
  *   "userid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *   "email": ".+"
  * })
  * @Method({"GET","HEAD"})
  */
 public function checkedituseremailAction(Request $request, $userid, $email)
 {
     $config = (new Configuration())->load(__DIR__ . "/../Resources/config/zacacia.yml");
     $ldapmanager = new LdapManager($config);
     $default_domain = $config->getDefaultDomain();
     $domain_config = $config->getDomainConfiguration($default_domain);
     $base_dn = $domain_config->getBaseDn();
     $userPeer = new UserPeer($base_dn);
     $emails = $userPeer->getLdapManager()->getRepository('user')->getUserByEmail($email);
     if (count($emails) == 1) {
         foreach ($emails as $email) {
             $user = $email;
         }
         if ($userid == $user->getEntryUUID()) {
             $count = 0;
         }
     } else {
         $count = count($emails);
     }
     $response = new JsonResponse();
     $response->setData(array('data' => $count));
     return $response;
 }