Beispiel #1
0
 /**
  * @Route("/check/groupname/{platformid}/{organizationid}/{name}", name="_check_groupname", 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})",
  *   "name": ".+"
  * })
  * @Method({"GET","HEAD"})
  */
 public function checkgroupnameAction(Request $request, $platformid, $organizationid, $name)
 {
     $platformPeer = new PlatformPeer();
     $platform_repository = $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);
     $base_dn = sprintf('ou=Groups,%s', $organization->getDn());
     $groupPeer = new GroupPeer($base_dn);
     $groups = $groupPeer->getLdapManager()->getRepository('group')->getGroupByName($name);
     $response = new JsonResponse();
     $response->setData(array('data' => count($groups)));
     return $response;
 }
Beispiel #2
0
 /**
  * @Route("/group/{platformid}/{organizationid}/{groupid}/delete", name="_group_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})",
  *     "groupid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})"
  * })
  */
 public function deleteAction(Request $request, $platformid, $organizationid, $groupid)
 {
     $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 {
         $groupPeer = new GroupPeer($organization->getDn());
         $groupPeer->deleteGroup($groupid, true);
     } catch (LdapConnectionException $e) {
         echo "Failed to delete group!" . PHP_EOL;
         echo $e->getMessage() . PHP_EOL;
     }
     return $this->redirectToRoute('_group', array('platformid' => $platform->getEntryUUID(), 'organizationid' => $organization->getEntryUUID()));
 }