Commit bc33d3912b489d8164677559f1caa37d86c0141c

Authored by Etienne Pallier
1 parent 2f26ec12
Exists in master and in 2 other branches dev, dev-IRAP

ldap test

src/Model/Table/LdapConnectionsTable.php
... ... @@ -501,249 +501,250 @@ class LdapConnectionsTable extends AppTable
501 501 // No connexion allowed without password
502 502 if (strlen(trim($user_password)) == 0) return FALSE;
503 503  
504   - // TODO: optimisation possible
505   - // 1) Search user in CACHE (DB)
506   - $user_fetched = $this->checkAndFetchLDAPUserFromDB($user_login, $user_password);
507   - $this->mydebugmsg("(1) user found in DB is:");
508   - $this->mydebugmsg($user_fetched);
509   - //TODO: A VIRER !!!
510   - $user_fetched = FALSE;
511   - // 2) If not CACHED, search user in LDAP
512   - if ($user_fetched === FALSE) {
513   - //$user_fetched = $this->checkAndFetchUserFromLdap($user_login, $user_password);
  504 + // TODO: optimisation possible
  505 + // 1) Search user in CACHE (DB)
  506 + $user_fetched = $this->checkAndFetchLDAPUserFromDB($user_login, $user_password);
  507 + $this->mydebugmsg("(1) user found in DB is:");
  508 + $this->mydebugmsg($user_fetched);
  509 + //TODO: A VIRER !!!
  510 + $user_fetched = FALSE;
  511 + // 2) If not CACHED, search user in LDAP
  512 + if ($user_fetched === FALSE) {
  513 + //$user_fetched = $this->checkAndFetchUserFromLdap($user_login, $user_password);
514 514  
515   - $just_these = [];
516   - // TODO: vérifier si cette ligne est bien utile ou pas... (avant on faisait ça)
517   - //if (! $this->ldap_authentified) $just_these = array("cn");
518   - // Construction du filtre avec le filtre de la base de données avec un & sur le login de l'utilisateur
519   - // Si aucun filtre n'est défini dans la base de données on aura juste (& ($this->authenticationType=$user_login))
520   - // ex: "(&(objectClass=person)(memberOf:1.2.840.113556.1.4.1941:=cn=ucbl.osu.cral,ou=groups,ou=27,ou=sim,ou=univ-lyon1,dc=univ-lyon1,dc=fr)(sAMAccountName=$user_login))";
521   - $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))";
522   - //TODO: optimisation, refactoriser si comportement général
523   - //$binddn .= ','.$this->baseDn;
524   - $user_fetched = $this->searchLdap($filter, $just_these, $user_login, $user_password);
525   - $this->mydebugmsg("(1) user found in LDAP is:");
526   - //$this->mydebugmsg($user_fetched);
527   - $this->mydebugmsg($user_fetched[0]);
528   - /* Voici un exemple de ce qui est dans $user_fetched (structure LDAP IRAP) :
  515 + $just_these = [];
  516 + // TODO: vérifier si cette ligne est bien utile ou pas... (avant on faisait ça)
  517 + //if (! $this->ldap_authentified) $just_these = array("cn");
  518 + // Construction du filtre avec le filtre de la base de données avec un & sur le login de l'utilisateur
  519 + // Si aucun filtre n'est défini dans la base de données on aura juste (& ($this->authenticationType=$user_login))
  520 + // ex: "(&(objectClass=person)(memberOf:1.2.840.113556.1.4.1941:=cn=ucbl.osu.cral,ou=groups,ou=27,ou=sim,ou=univ-lyon1,dc=univ-lyon1,dc=fr)(sAMAccountName=$user_login))";
  521 + $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))";
  522 + //TODO: optimisation, refactoriser si comportement général
  523 + //$binddn .= ','.$this->baseDn;
  524 + $user_fetched = $this->searchLdap($filter, $just_these, $user_login, $user_password);
  525 + $this->mydebugmsg("(1) user found in LDAP is:");
  526 + //$this->mydebugmsg($user_fetched);
  527 + $this->mydebugmsg($user_fetched[0]);
  528 + /* Voici un exemple de ce qui est dans $user_fetched (structure LDAP IRAP) :
529 529  
530   - 'sn' => [
531   - 'count' => (int) 1,
532   - (int) 0 => 'Pallier'
533   - ],
534   - (int) 14 => 'sn',
535   - 'givenname' => [
536   - 'count' => (int) 1,
537   - (int) 0 => 'Etienne'
538   - ],
  530 + // ce qui est retourné par le fake ldap (imitation bien faite non ?)
  531 + [
  532 + 'sn' => [
  533 + (int) 0 => 'Pallier'
  534 + ],
  535 + 'mail' => [
  536 + (int) 0 => 'Etienne.Pallier@irap.omp.eu'
  537 + ],
  538 + 'givenname' => [
  539 + (int) 0 => 'Etienne'
  540 + ],
  541 + 'uid' => [
  542 + (int) 0 => 'epallier'
  543 + ],
  544 + 'userpassword' => [
  545 + (int) 0 => '<mot de passe crypté>'
  546 + ]
  547 + ]
539 548  
  549 + // VRAI LDAP, juste un extrait utile :
  550 + [
  551 + 'sn' => [
  552 + 'count' => (int) 1,
  553 + (int) 0 => 'Pallier'
  554 + ],
  555 + (int) 14 => 'sn',
  556 + 'givenname' => [
  557 + 'count' => (int) 1,
  558 + (int) 0 => 'Etienne'
  559 + ],
  560 + ]
540 561  
541   - [
542   - 'sn' => [
543   - (int) 0 => 'Pallier'
544   - ],
545   - 'mail' => [
546   - (int) 0 => 'Etienne.Pallier@irap.omp.eu'
547   - ],
548   - 'givenname' => [
549   - (int) 0 => 'Etienne'
550   - ],
551   - 'uid' => [
552   - (int) 0 => 'epallier'
553   - ],
554   - 'userpassword' => [
555   - (int) 0 => '<mot de passe crypté>'
556   - ]
557   - ]
  562 + // VRAI LDAP, au complet :
  563 + [
  564 + 'cn' => [
  565 + 'count' => (int) 1,
  566 + (int) 0 => 'Etienne Pallier'
  567 + ],
  568 + (int) 0 => 'cn',
  569 + 'homedirectory' => [
  570 + 'count' => (int) 1,
  571 + (int) 0 => '/home/epallier'
  572 + ],
  573 + (int) 1 => 'homedirectory',
  574 + 'uidnumber' => [
  575 + 'count' => (int) 1,
  576 + (int) 0 => '20172'
  577 + ],
  578 + (int) 2 => 'uidnumber',
  579 + 'objectclass' => [
  580 + 'count' => (int) 9,
  581 + (int) 0 => 'top',
  582 + (int) 1 => 'person',
  583 + (int) 2 => 'organizationalPerson',
  584 + (int) 3 => 'inetOrgPerson',
  585 + (int) 4 => 'posixAccount',
  586 + (int) 5 => 'shadowAccount',
  587 + (int) 6 => 'irap',
  588 + (int) 7 => 'hostObject',
  589 + (int) 8 => 'sambaSamAccount'
  590 + ],
  591 + (int) 3 => 'objectclass',
  592 + 'sambasid' => [
  593 + 'count' => (int) 1,
  594 + (int) 0 => 'S-1-5-21-3149873848-2002230563-1027543705-41344'
  595 + ],
  596 + (int) 4 => 'sambasid',
  597 + 'mail' => [
  598 + 'count' => (int) 1,
  599 + (int) 0 => 'Etienne.Pallier@irap.omp.eu'
  600 + ],
  601 + (int) 5 => 'mail',
  602 + 'olddn' => [
  603 + 'count' => (int) 1,
  604 + (int) 0 => 'uid=pallier,ou=users,ou=laboratoire,dc=cesr,dc=fr'
  605 + ],
  606 + (int) 6 => 'olddn',
  607 + 'userpassword' => [
  608 + 'count' => (int) 1,
  609 + (int) 0 => '{SASL}epallier@IRAP.OMP.EU'
  610 + ],
  611 + (int) 7 => 'userpassword',
  612 + 'sambantpassword' => [
  613 + 'count' => (int) 1,
  614 + (int) 0 => 'ED9A0ECE0C6C7560A8DDF6A23B2C7C36'
  615 + ],
  616 + (int) 8 => 'sambantpassword',
  617 + 'sambapwdlastset' => [
  618 + 'count' => (int) 1,
  619 + (int) 0 => '1317291687'
  620 + ],
  621 + (int) 9 => 'sambapwdlastset',
  622 + 'loginshell' => [
  623 + 'count' => (int) 1,
  624 + (int) 0 => '/bin/bash'
  625 + ],
  626 + (int) 10 => 'loginshell',
  627 + 'shadowexpire' => [
  628 + 'count' => (int) 1,
  629 + (int) 0 => '-1'
  630 + ],
  631 + (int) 11 => 'shadowexpire',
  632 + 'host' => [
  633 + 'count' => (int) 3,
  634 + (int) 0 => 'gitlab1.irap.omp.eu',
  635 + (int) 1 => 'gw.irap.omp.eu',
  636 + (int) 2 => 'version2.irap.omp.eu'
  637 + ],
  638 + (int) 12 => 'host',
  639 + 'uid' => [
  640 + 'count' => (int) 1,
  641 + (int) 0 => 'epallier'
  642 + ],
  643 + (int) 13 => 'uid',
  644 + 'sn' => [
  645 + 'count' => (int) 1,
  646 + (int) 0 => 'Pallier'
  647 + ],
  648 + (int) 14 => 'sn',
  649 + 'givenname' => [
  650 + 'count' => (int) 1,
  651 + (int) 0 => 'Etienne'
  652 + ],
  653 + (int) 15 => 'givenname',
  654 + 'gecos' => [
  655 + 'count' => (int) 1,
  656 + (int) 0 => 'Etienne.Pallier'
  657 + ],
  658 + (int) 16 => 'gecos',
  659 + 'gidnumber' => [
  660 + 'count' => (int) 1,
  661 + (int) 0 => '2001'
  662 + ],
  663 + (int) 17 => 'gidnumber',
  664 + 'tagmail' => [
  665 + 'count' => (int) 1,
  666 + (int) 0 => 'Oui'
  667 + ],
  668 + (int) 18 => 'tagmail',
  669 + 'compteinfo' => [
  670 + 'count' => (int) 1,
  671 + (int) 0 => 'Oui'
  672 + ],
  673 + (int) 19 => 'compteinfo',
  674 + 'arrivaldate' => [
  675 + 'count' => (int) 1,
  676 + (int) 0 => '01/01/1933'
  677 + ],
  678 + (int) 20 => 'arrivaldate',
  679 + 'birthday' => [
  680 + 'count' => (int) 1,
  681 + (int) 0 => '07/08/1968'
  682 + ],
  683 + (int) 21 => 'birthday',
  684 + 'telephonenumber' => [
  685 + 'count' => (int) 1,
  686 + (int) 0 => '0561556648'
  687 + ],
  688 + (int) 22 => 'telephonenumber',
  689 + 'roomnumber' => [
  690 + 'count' => (int) 1,
  691 + (int) 0 => 'J039'
  692 + ],
  693 + (int) 23 => 'roomnumber',
  694 + 'mailperso' => [
  695 + 'count' => (int) 1,
  696 + (int) 0 => 'N/A'
  697 + ],
  698 + (int) 24 => 'mailperso',
  699 + 'title' => [
  700 + 'count' => (int) 1,
  701 + (int) 0 => 'M'
  702 + ],
  703 + (int) 25 => 'title',
  704 + 'site' => [
  705 + 'count' => (int) 1,
  706 + (int) 0 => 'Roche'
  707 + ],
  708 + (int) 26 => 'site',
  709 + 'manager' => [
  710 + 'count' => (int) 1,
  711 + (int) 0 => 'uid=mgiard,ou=users,dc=irap,dc=omp,dc=eu'
  712 + ],
  713 + (int) 27 => 'manager',
  714 + 'statut1' => [
  715 + 'count' => (int) 1,
  716 + (int) 0 => 'ITA'
  717 + ],
  718 + (int) 28 => 'statut1',
  719 + 'o' => [
  720 + 'count' => (int) 1,
  721 + (int) 0 => 'UPS'
  722 + ],
  723 + (int) 29 => 'o',
  724 + 'gt1' => [
  725 + 'count' => (int) 1,
  726 + (int) 0 => 'PEPS'
  727 + ],
  728 + (int) 30 => 'gt1',
  729 + 'gt2' => [
  730 + 'count' => (int) 1,
  731 + (int) 0 => 'GAHEC'
  732 + ],
  733 + (int) 31 => 'gt2',
  734 + 'statut2' => [
  735 + 'count' => (int) 1,
  736 + (int) 0 => 'GT2I'
  737 + ],
  738 + (int) 32 => 'statut2',
  739 + 'affichageannuaire' => [
  740 + 'count' => (int) 1,
  741 + (int) 0 => 'Oui'
  742 + ],
  743 + (int) 33 => 'affichageannuaire',
  744 + 'count' => (int) 34,
  745 + 'dn' => 'uid=epallier,ou=users,dc=irap,dc=omp,dc=eu'
  746 + ]
558 747  
559   - [
560   - 'count' => (int) 1,
561   - (int) 0 => [
562   - 'cn' => [
563   - 'count' => (int) 1,
564   - (int) 0 => 'Etienne Pallier'
565   - ],
566   - (int) 0 => 'cn',
567   - 'homedirectory' => [
568   - 'count' => (int) 1,
569   - (int) 0 => '/home/epallier'
570   - ],
571   - (int) 1 => 'homedirectory',
572   - 'uidnumber' => [
573   - 'count' => (int) 1,
574   - (int) 0 => '20172'
575   - ],
576   - (int) 2 => 'uidnumber',
577   - 'objectclass' => [
578   - 'count' => (int) 9,
579   - (int) 0 => 'top',
580   - (int) 1 => 'person',
581   - (int) 2 => 'organizationalPerson',
582   - (int) 3 => 'inetOrgPerson',
583   - (int) 4 => 'posixAccount',
584   - (int) 5 => 'shadowAccount',
585   - (int) 6 => 'irap',
586   - (int) 7 => 'hostObject',
587   - (int) 8 => 'sambaSamAccount'
588   - ],
589   - (int) 3 => 'objectclass',
590   - 'sambasid' => [
591   - 'count' => (int) 1,
592   - (int) 0 => 'S-1-5-21-3149873848-2002230563-1027543705-41344'
593   - ],
594   - (int) 4 => 'sambasid',
595   - 'mail' => [
596   - 'count' => (int) 1,
597   - (int) 0 => 'Etienne.Pallier@irap.omp.eu'
598   - ],
599   - (int) 5 => 'mail',
600   - 'olddn' => [
601   - 'count' => (int) 1,
602   - (int) 0 => 'uid=pallier,ou=users,ou=laboratoire,dc=cesr,dc=fr'
603   - ],
604   - (int) 6 => 'olddn',
605   - 'userpassword' => [
606   - 'count' => (int) 1,
607   - (int) 0 => '{SASL}epallier@IRAP.OMP.EU'
608   - ],
609   - (int) 7 => 'userpassword',
610   - 'sambantpassword' => [
611   - 'count' => (int) 1,
612   - (int) 0 => 'ED9A0ECE0C6C7560A8DDF6A23B2C7C36'
613   - ],
614   - (int) 8 => 'sambantpassword',
615   - 'sambapwdlastset' => [
616   - 'count' => (int) 1,
617   - (int) 0 => '1317291687'
618   - ],
619   - (int) 9 => 'sambapwdlastset',
620   - 'loginshell' => [
621   - 'count' => (int) 1,
622   - (int) 0 => '/bin/bash'
623   - ],
624   - (int) 10 => 'loginshell',
625   - 'shadowexpire' => [
626   - 'count' => (int) 1,
627   - (int) 0 => '-1'
628   - ],
629   - (int) 11 => 'shadowexpire',
630   - 'host' => [
631   - 'count' => (int) 3,
632   - (int) 0 => 'gitlab1.irap.omp.eu',
633   - (int) 1 => 'gw.irap.omp.eu',
634   - (int) 2 => 'version2.irap.omp.eu'
635   - ],
636   - (int) 12 => 'host',
637   - 'uid' => [
638   - 'count' => (int) 1,
639   - (int) 0 => 'epallier'
640   - ],
641   - (int) 13 => 'uid',
642   - 'sn' => [
643   - 'count' => (int) 1,
644   - (int) 0 => 'Pallier'
645   - ],
646   - (int) 14 => 'sn',
647   - 'givenname' => [
648   - 'count' => (int) 1,
649   - (int) 0 => 'Etienne'
650   - ],
651   - (int) 15 => 'givenname',
652   - 'gecos' => [
653   - 'count' => (int) 1,
654   - (int) 0 => 'Etienne.Pallier'
655   - ],
656   - (int) 16 => 'gecos',
657   - 'gidnumber' => [
658   - 'count' => (int) 1,
659   - (int) 0 => '2001'
660   - ],
661   - (int) 17 => 'gidnumber',
662   - 'tagmail' => [
663   - 'count' => (int) 1,
664   - (int) 0 => 'Oui'
665   - ],
666   - (int) 18 => 'tagmail',
667   - 'compteinfo' => [
668   - 'count' => (int) 1,
669   - (int) 0 => 'Oui'
670   - ],
671   - (int) 19 => 'compteinfo',
672   - 'arrivaldate' => [
673   - 'count' => (int) 1,
674   - (int) 0 => '01/01/1933'
675   - ],
676   - (int) 20 => 'arrivaldate',
677   - 'birthday' => [
678   - 'count' => (int) 1,
679   - (int) 0 => '07/08/1968'
680   - ],
681   - (int) 21 => 'birthday',
682   - 'telephonenumber' => [
683   - 'count' => (int) 1,
684   - (int) 0 => '0561556648'
685   - ],
686   - (int) 22 => 'telephonenumber',
687   - 'roomnumber' => [
688   - 'count' => (int) 1,
689   - (int) 0 => 'J039'
690   - ],
691   - (int) 23 => 'roomnumber',
692   - 'mailperso' => [
693   - 'count' => (int) 1,
694   - (int) 0 => 'N/A'
695   - ],
696   - (int) 24 => 'mailperso',
697   - 'title' => [
698   - 'count' => (int) 1,
699   - (int) 0 => 'M'
700   - ],
701   - (int) 25 => 'title',
702   - 'site' => [
703   - 'count' => (int) 1,
704   - (int) 0 => 'Roche'
705   - ],
706   - (int) 26 => 'site',
707   - 'manager' => [
708   - 'count' => (int) 1,
709   - (int) 0 => 'uid=mgiard,ou=users,dc=irap,dc=omp,dc=eu'
710   - ],
711   - (int) 27 => 'manager',
712   - 'statut1' => [
713   - 'count' => (int) 1,
714   - (int) 0 => 'ITA'
715   - ],
716   - (int) 28 => 'statut1',
717   - 'o' => [
718   - 'count' => (int) 1,
719   - (int) 0 => 'UPS'
720   - ],
721   - (int) 29 => 'o',
722   - 'gt1' => [
723   - 'count' => (int) 1,
724   - (int) 0 => 'PEPS'
725   - ],
726   - (int) 30 => 'gt1',
727   - 'gt2' => [
728   - 'count' => (int) 1,
729   - (int) 0 => 'GAHEC'
730   - ],
731   - (int) 31 => 'gt2',
732   - 'statut2' => [
733   - 'count' => (int) 1,
734   - (int) 0 => 'GT2I'
735   - ],
736   - (int) 32 => 'statut2',
737   - 'affichageannuaire' => [
738   - 'count' => (int) 1,
739   - (int) 0 => 'Oui'
740   - ],
741   - (int) 33 => 'affichageannuaire',
742   - 'count' => (int) 34,
743   - 'dn' => 'uid=epallier,ou=users,dc=irap,dc=omp,dc=eu'
744   - ]
745   - ]
746   -
747 748  
748 749 */
749 750 // CACHE the new user in DB for next time
... ...
src/Template/Materiels/view.ctp
... ... @@ -218,7 +218,9 @@ $CAN_PRINT_LABEL = $IS_VALIDATED &amp;&amp; $configuration-&gt;hasPrinter &amp;&amp; $USER_IS_ADMIN
218 218 }
219 219  
220 220 // QRCODE (Url)
221   - //debug($this->request->env('REQUEST_SCHEME'));
  221 + debug($this->request->env('REQUEST_SCHEME'));
  222 + debug($this->request->env('HTTP_REFERER')); // 'http://labinvent.test/materiels
  223 + debug($this->request);
222 224 $qrCodeUrl = $this->request->env('REQUEST_SCHEME').'://' . $this->request->env('SERVER_NAME') . $this->request->env('REQUEST_URI');
223 225  
224 226 $this->request->getSession()->write("qrUrl", $qrCodeUrl);
... ...