Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Support
  3. Using FOP2 Phonebook with LDAP server

Using FOP2 Phonebook with LDAP server

Scheduled Pinned Locked Moved Support
14 Posts 3 Posters 436 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    dsisevran
    wrote on last edited by
    #3

    Dear,
    Is there any update concering this request?
    Regards.

    1 Reply Last reply
    0
    • A
      A
      aratel
      wrote on last edited by
      #4

      Hi, not for now...

      1 Reply Last reply
      0
      • N
        N
        nicolas
        wrote on last edited by
        #5

        FOP2 has its own phonebook/contacts and scripts to tie that with the switchboard itself. Code is there for users to modify if they so like/need.
        The dial box will query the visual_phonebook table that the contacts app uses, but it can be modified, as I expalined originally, as it is a standard php script. You are free to modify it to query whatever you want instead of FOP2 tables.

        In any case, that feature is not on the roadmap, you can purchase development time if you want us to work on this particular integration, or just look at doing it yourself, it is just one php script (vphonebook.php) that is used for querying contacts from the dial box.

        1 Reply Last reply
        0
        • D
          D
          dsisevran
          wrote on last edited by
          #6

          Thanks for the answer. Will try to do something before paid for a full licence. I have also see VOP which could do the trick. Will give a try.
          Regards.

          1 Reply Last reply
          0
          • D
            D
            dsisevran
            wrote on last edited by
            #7

            Whitch syntax does the result have to be return for matching contact form query?

            1 Reply Last reply
            0
            • N
              N
              nicolas
              wrote on last edited by
              #8

              Hi,
              Ideallly you should work directly by modifying the vphonebook.php script and adding your custom query to it, replacing or not the ones provided. Return format is a json array like:

              [
                {"name":"","value":"John  <1234567>"},
                {"name":"","value":"Peter  <7654321>"}
              ]
              
              1 Reply Last reply
              0
              • D
                D
                dsisevran
                wrote on last edited by
                #9

                Thanks 😉
                Yes I am working on a separate php file for testing only and then I will modify vphonebook.php.

                1 Reply Last reply
                0
                • D
                  D
                  dsisevran
                  wrote on last edited by
                  #10

                  I have wrote a little script to query on LDAP and formating the result in a json array but not working when adding it in vphonebook.php

                  <?php
                  
                  // ---------------------------- VARIABLES ----------------------------
                  $ldapURL = 'LDAP_URL';
                  $ldapPort = 389; // Port par defaut = 389
                  $ldapVersionProtocole = 3; // Version par defaut = 2
                  $ldapIdentifiant = 'cn=ADMIN,dc=DOMAIN,dc=COM';
                  $ldapMotDePasse = 'PASSWD';
                  
                  // ---------------------------- CONNEXION ----------------------------
                  $ldap = ldap_connect($ldapURL, $ldapPort);
                  if (false === $ldap) die('Echec de la connexion');
                  ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, $ldapVersionProtocole);
                  $retour = ldap_bind($ldap, $ldapIdentifiant, $ldapMotDePasse);
                  if (false === $retour) die('Echec de l\'authentification (ou de la connexion)');
                  
                  // ---------------------------- RECHERCHE ----------------------------
                  $dn = "OU=PERSON,DC=DOMAIN,DC=COM";
                  $recherche = "UID=*$texto*";
                  $requete = ldap_search($ldap, $dn, $recherche);
                  if (false === $requete) die('La recherche a echoue');
                  
                  // ---------------------------- RESULTAT ----------------------------
                  $resultats = ldap_get_entries($ldap, $requete);
                  $myArray = array();
                  for ($i=0; $i<$resultats["count"]; $i++) {
                      $myArray[] = "{\"name\":\"\",\"value\":\"" . $resultats[$i]["cn"][0] . " <" . $resultats[$i]["telephonenumber"][0] . ">\"}";
                  }
                  
                  // ---------------------------- FORMATAGE ----------------------------
                  //print_r($myArray);
                  $results = json_encode($myArray,JSON_UNESCAPED_UNICODE);
                  $results = str_replace('\"', '"', $results);
                  $results = str_replace('"{', '{', $results);
                  $results = str_replace('}"', '}', $results);
                  
                  // ---------------------------- FERMETURE ----------------------------
                  ldap_close($ldap);
                  
                  return $results;
                  
                  ?>
                  
                  1 Reply Last reply
                  0
                  • N
                    N
                    nicolas
                    wrote on last edited by
                    #11

                    Hi,

                    You must add before your code something like this:

                    $texto     = $_REQUEST['term'];
                    

                    What happens when you use the dial box and start typing something?

                    1 Reply Last reply
                    0
                    • D
                      D
                      dsisevran
                      wrote on last edited by
                      #12

                      Thank Nicolas for your help.
                      Finally as I only use ldap for my search my vphonebook.php look like

                      <?php
                      
                      $texto     = $_REQUEST['term'];
                      
                      // ---------------------------- VARIABLES ----------------------------
                      $ldapURL = 'LDAP_URL';
                      $ldapPort = 389; // Port par defaut = 389
                      $ldapVersionProtocole = 3; // Version par defaut = 2
                      $ldapIdentifiant = 'cn=ADMIN,dc=DOMAIN,dc=COM';
                      $ldapMotDePasse = 'PASSWD';
                      
                      // ---------------------------- CONNEXION ----------------------------
                      $ldap = ldap_connect($ldapURL, $ldapPort);
                      if (false === $ldap) die('Echec de la connexion');
                      ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, $ldapVersionProtocole);
                      $retour = ldap_bind($ldap, $ldapIdentifiant, $ldapMotDePasse);
                      if (false === $retour) die('Echec de l\'authentification (ou de la connexion)');
                      
                      // ---------------------------- RECHERCHE ----------------------------
                      $dn = "OU=PERSON,DC=DOMAIN,DC=COM";
                      $recherche = "UID=*$texto*";
                      $requete = ldap_search($ldap, $dn, $recherche);
                      if (false === $requete) die('La recherche a echoue');
                      
                      // ---------------------------- RESULTAT ----------------------------
                      $resultats = ldap_get_entries($ldap, $requete);
                      $myArray = array();
                      for ($i=0; $i<$resultats["count"]; $i++) {
                          $myArray[] = "{\"name\":\"\",\"value\":\"" . $resultats[$i]["cn"][0] . " <" . $resultats[$i]["telephonenumber"][0] . ">\"}";
                      }
                      
                      // ---------------------------- FORMATAGE ----------------------------
                      //print_r($myArray);
                      $results = json_encode($myArray,JSON_UNESCAPED_UNICODE);
                      $results = str_replace('\"', '"', $results);
                      $results = str_replace('"{', '{', $results);
                      $results = str_replace('}"', '}', $results);
                      
                      // ---------------------------- FERMETURE ----------------------------
                      ldap_close($ldap);
                      
                      echo $results;
                      
                      ?>
                      
                      1 Reply Last reply
                      0
                      • N
                        N
                        nicolas
                        wrote on last edited by
                        #13

                        Here is the full fixed code:

                        <?php
                        $texto     = $_REQUEST['term'];
                        
                        // ---------------------------- VARIABLES ----------------------------
                        $ldapURL = 'LDAP_URL';
                        $ldapPort = 389; // Port par defaut = 389
                        $ldapVersionProtocole = 3; // Version par defaut = 2
                        $ldapIdentifiant = 'cn=ADMIN,dc=DOMAIN,dc=COM';
                        $ldapMotDePasse = 'PASSWD';
                        
                        // ---------------------------- CONNEXION ----------------------------
                        $ldap = ldap_connect($ldapURL, $ldapPort);
                        if (false === $ldap) die('Echec de la connexion');
                        ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, $ldapVersionProtocole);
                        $retour = ldap_bind($ldap, $ldapIdentifiant, $ldapMotDePasse);
                        if (false === $retour) die('Echec de l\'authentification (ou de la connexion)');
                        
                        // ---------------------------- RECHERCHE ----------------------------
                        $dn = "OU=PERSON,DC=DOMAIN,DC=COM";
                        $recherche = "UID=*$texto*";
                        $requete = ldap_search($ldap, $dn, $recherche);
                        if (false === $requete) die('La recherche a echoue');
                        
                        // ---------------------------- RESULTAT ----------------------------
                        $resultats = ldap_get_entries($ldap, $requete);
                        $myArray = array();
                        for ($i=0; $i<$resultats["count"]; $i++) {
                            $myArray[] = "{\"name\":\"\",\"value\":\"" . $resultats[$i]["cn"][0] . " <" . $resultats[$i]["telephonenumber"][0] . ">\"}";
                        }
                        
                        // ---------------------------- FORMATAGE ----------------------------
                        //print_r($myArray);
                        $results = json_encode($myArray,JSON_UNESCAPED_UNICODE);
                        $results = str_replace('\"', '"', $results);
                        $results = str_replace('"{', '{', $results);
                        $results = str_replace('}"', '}', $results);
                        
                        // ---------------------------- FERMETURE ----------------------------
                        ldap_close($ldap);
                        
                        echo $results;
                        
                        ?>
                        
                        1 Reply Last reply
                        0
                        • D
                          D
                          dsisevran
                          wrote on last edited by
                          #14

                          Yes! Thanks for pointing my fault. As I'm not using this query in a function, I forgot changing return $results; to echo $results;
                          I firstly trying to add this code inside the original in a function with no luck. Then I have blank vphonebook.php and fill it with this code only but still not working. Finally Nicolas help me to fix the problem.

                          1 Reply Last reply
                          0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          Powered by NodeBB Contributors
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups