<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ricerca autocomplete jquey su Active Directory Windows]]></title><description><![CDATA[<p dir="auto">Buongiorno a tutti<br />
premesso che non sono un esperto, sto cercando di fare una ricerca per user o nome su AD.<br />
Ho trovato degli esempi e ho implementato due pagine:</p>
<ul>
<li>test_ad.php</li>
<li>leggi.php</li>
</ul>
<p dir="auto">Non riesco a passare variabili (credo) e  la ricerca rilascia tutti i nominativi ma non ricerca per nome.<br />
Potete aiutarmi? Grazie in anticipo.</p>
<p dir="auto">test_ad.php</p>
<pre><code class="language-php">&lt;!DOCTYPE html&gt;
&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/title&gt;
          &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; /&gt;
          &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;;
          &lt;style&gt;
          ul{
                background-color:#eee;
                cursor:pointer;
          }
          li{
                padding:12px;
          }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;br /&gt;&lt;br /&gt;
          &lt;div class="container" style="width:500px;" action="test_ad.php" method="POST"&gt;
                &lt;h3 align="center"&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/h3&gt;&lt;br /&gt;
                &lt;label&gt;Enter Name&lt;/label&gt;
                &lt;input type="text" name="search-box" id="search-box" class="form-control" placeholder="Enter Name" /&gt;
                &lt;div id="suggesstion-box"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
&lt;/html&gt;
&lt;script&gt;
$(document).ready(function(){
      $('#search-box').keyup(function(){
          //var query = $('#search-box').val();
          var query = $('#search-box').val();
          if(query != '')
          {
                $.ajax({
                    url:"leggi.php",
                    method:"REQUEST",
                    data:{query:query},
                    success:function(data)
                    {
                          $('#suggesstion-box').fadeIn();
                          $('#suggesstion-box').html(data);
                    }
                });
          }
      });
      $(document).on('click', 'li', function(){
          $('#search-box').val($(this).text());
          $('#suggesstion-box').fadeOut();
      minLength: 3
      });
});
&lt;/script&gt;
</code></pre>
<p dir="auto">leggi.php</p>
<pre><code class="language-php">&lt;!DOCTYPE html&gt;
&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/title&gt;
          &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; /&gt;
          &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;;
          &lt;style&gt;
          ul{
                background-color:#eee;
                cursor:pointer;
          }
          li{
                padding:12px;
          }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;br /&gt;&lt;br /&gt;
          &lt;div class="container" style="width:500px;" action="test_ad.php" method="POST"&gt;
                &lt;h3 align="center"&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/h3&gt;&lt;br /&gt;
                &lt;label&gt;Enter Name&lt;/label&gt;
                &lt;input type="text" name="search-box" id="search-box" class="form-control" placeholder="Enter Name" /&gt;
                &lt;div id="suggesstion-box"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
&lt;/html&gt;
&lt;script&gt;
$(document).ready(function(){
      $('#search-box').keyup(function(){
          //var query = $('#search-box').val();
          var query = $('#search-box').val();
          if(query != '')
          {
                $.ajax({
                    url:"leggi.php",
                    method:"REQUEST",
                    data:{query:query},
                    success:function(data)
                    {
                          $('#suggesstion-box').fadeIn();
                          $('#suggesstion-box').html(data);
                    }
                });
          }
      });
      $(document).on('click', 'li', function(){
          $('#search-box').val($(this).text());
          $('#suggesstion-box').fadeOut();
      minLength: 3
      });
});
&lt;/script&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/239073/ricerca-autocomplete-jquey-su-active-directory-windows</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 11:40:10 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/239073.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Oct 2019 09:03:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ricerca autocomplete jquey su Active Directory Windows on Thu, 24 Oct 2019 14:33:29 GMT]]></title><description><![CDATA[<p dir="auto">Grazie!<br />
stasera provo.</p>
]]></description><link>https://dev.connect.gt/post/1260462</link><guid isPermaLink="true">https://dev.connect.gt/post/1260462</guid><dc:creator><![CDATA[linno]]></dc:creator><pubDate>Thu, 24 Oct 2019 14:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to Ricerca autocomplete jquey su Active Directory Windows on Thu, 24 Oct 2019 14:08:48 GMT]]></title><description><![CDATA[<p dir="auto">Ciao,</p>
<p dir="auto">Nella chiamata tramite ajax utilizzi</p>
<pre><code>method:REQUEST
</code></pre>
<p dir="auto">non esiste nessun metodo HTTP che si chiami request.</p>
<p dir="auto">Devi utilizzare GET oppure POST e lato PHP recuperi il dato con $_GET o $_POST.</p>
<p dir="auto">Nella chiamata ajax non hai nemmeno specificato il formato dei dati, ti consiglio di utilizzare JSON. Dai un occhio alla doc <a href="https://api.jquery.com/jQuery.ajax/" rel="nofollow ugc">https://api.jquery.com/jQuery.ajax/</a></p>
]]></description><link>https://dev.connect.gt/post/1260455</link><guid isPermaLink="true">https://dev.connect.gt/post/1260455</guid><dc:creator><![CDATA[flaviors200]]></dc:creator><pubDate>Thu, 24 Oct 2019 14:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to Ricerca autocomplete jquey su Active Directory Windows on Thu, 24 Oct 2019 13:07:06 GMT]]></title><description><![CDATA[<p dir="auto">[h=2]errata corrige codice esatto[/h] 				   						 						 							 						 				 					 						 							La pagina leggi.php funziona se nella url passo la variabile,  come posso inviare la variabile dalla pagina con il form di ricerca  (test_ad.php)? Non riesco a capire.<br />
grazie</p>
<pre><code> 		 			 			 				 					![](https://forum.html.it/forum/images/misc/quote_icon.png) Originariamente inviata da **Linnox** 					[![](https://forum.html.it/forum/images/buttons/viewpost-right.png)](https://forum.html.it/forum/showthread.php?p=25545792#post25545792) 				
			Buongiorno a tutti
</code></pre>
<p dir="auto">premesso che non sono un esperto, sto cercando di fare una ricerca per user o nome su AD.<br />
Ho trovato degli esempi e ho implementato due pagine:</p>
<ul>
<li>test_ad.php</li>
<li>leggi.php</li>
</ul>
<p dir="auto">Non riesco a passare variabili (credo) e  la ricerca rilascia tutti i nominativi ma non ricerca per nome.<br />
Potete aiutarmi? Grazie in anticipo.</p>
<p dir="auto">test_ad.php<br />
Codice PHP:<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/title&gt;<br />
&lt;link rel="stylesheet" href="<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="nofollow ugc">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css</a>"; /&gt;<br />
&lt;script src="<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" rel="nofollow ugc">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js</a>"&gt;&lt;/script&gt;;<br />
&lt;script src="<a href="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" rel="nofollow ugc">https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js</a>"&gt;&lt;/script&gt;;<br />
&lt;style&gt;<br />
ul{<br />
background-color:#eee;<br />
cursor:pointer;<br />
}<br />
li{<br />
padding:12px;<br />
}<br />
&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;br /&gt;&lt;br /&gt;<br />
&lt;div class="container" style="width:500px;" action="test_ad.php" method="POST"&gt;<br />
&lt;h3 align="center"&gt;Autocomplete textbox using jQuery, PHP and LDAP&lt;/h3&gt;&lt;br /&gt;<br />
&lt;label&gt;Enter Name&lt;/label&gt;<br />
&lt;input type="text" name="search-box" id="search-box" class="form-control" placeholder="Enter Name" /&gt;<br />
&lt;div id="suggesstion-box"&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
&lt;script&gt;<br />
$(document).ready(function(){<br />
$('#search-box').keyup(function(){<br />
//var query = $('#search-box').val();<br />
var query = $('#search-box').val();<br />
if(query != '')<br />
{<br />
$.ajax({<br />
url:"leggi.php",<br />
method:"REQUEST",<br />
data:{query:query},<br />
success:function(data)<br />
{<br />
$('#suggesstion-box').fadeIn();<br />
$('#suggesstion-box').html(data);<br />
}<br />
});<br />
}<br />
});<br />
$(document).on('click', 'li', function(){<br />
$('#search-box').val($(this).text());<br />
$('#suggesstion-box').fadeOut();<br />
minLength: 3<br />
});<br />
});<br />
&lt;/script&gt;</p>
<p dir="auto">leggi.php</p>
<pre><code>Codice PHP:
 set_time_limit(30);
</code></pre>
<p dir="auto">error_reporting(E_ALL);<br />
ini_set('error_reporting', E_ALL);<br />
ini_set('display_errors',1);<br />
$key = $_REQUEST['search-box'];<br />
///echo "".$key."&lt;br&gt;";<br />
// config<br />
$ldapserver = 'local';<br />
$ldapuser   = 'use';<br />
$ldappass   = 'password';<br />
$ldaptree   = "OU=xx,DC=xxx,DC=xxx";</p>
<p dir="auto">// connect<br />
$ldapconn = ldap_connect($ldapserver) or die("Could not connect to LDAP server.");<br />
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);<br />
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);<br />
if($ldapconn) {</p>
<pre><code>// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass) or die ("Error trying to bind: ".ldap_error($ldapconn));
// verify binding
if ($ldapbind) {
    echo "LDAP bind successful...&lt;br /&gt;&lt;br /&gt;";

$search_filter = '(&amp;(objectCategory=person)(objectClass=user)(sn=*'. $key .'*))';
$attributes = array();
$attributes[] = 'cn';
$attributes[] = 'mail';
$attributes[] = 'samaccountname';
$attributes[] = 'sn';
$result = ldap_search($ldapconn,$ldaptree,$search_filter,$attributes) or die ("Error in search query: ".ldap_error($ldapconn));
ldap_sort($ldapconn,$result,"sn");
$data = ldap_get_entries($ldapconn, $result);
   

    // iterate over array and print data for each entry
    echo '&lt;h1&gt;Utenti&lt;/h1&gt;';
    
    for ($i=0; $i&lt;$data["count"]; $i++) {
        //echo "dn is: ". $data[$i]["dn"] ."&lt;br /&gt;";
        echo "User: ". $data[$i]["cn"][0] ."&lt;br /&gt;";
        if(isset($data[$i]["mail"][0])) {
            echo "Email: ". $data[$i]["mail"][0] ."&lt;br /&gt;&lt;br /&gt;";
        } else {
            echo "Email: None&lt;br /&gt;&lt;br /&gt;";
        }
    }
    echo "".$key."&lt;br&gt;";
    // print number of entries found
    echo "Number of entries found: " . ldap_count_entries($ldapconn, $result);
} else {
    echo "LDAP bind failed...";
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">// all done? clean up<br />
ldap_close($ldapconn);</p>
]]></description><link>https://dev.connect.gt/post/1260459</link><guid isPermaLink="true">https://dev.connect.gt/post/1260459</guid><dc:creator><![CDATA[linno]]></dc:creator><pubDate>Thu, 24 Oct 2019 13:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Ricerca autocomplete jquey su Active Directory Windows on Thu, 24 Oct 2019 10:08:39 GMT]]></title><description><![CDATA[<p dir="auto">Ho sbagliato a inserire il codice di leggi.php! come posso correggere il post?<br />
grazie</p>
<pre><code class="language-php">&lt;?php 
set_time_limit(30);
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors',1);

// config
$ldapserver = 'sever';
$ldapuser   = 'user';
$ldappass   = 'password';
$ldaptree   = "OU=user,DC=pippo,DC=it";

// connect
$ldapconn = ldap_connect($ldapserver) or die("Could not connect to LDAP server.");

if($ldapconn) {
    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass) or die ("Error trying to bind: ".ldap_error($ldapconn));
    // verify binding
    if ($ldapbind) {
        echo "LDAP bind successful...&lt;br /&gt;&lt;br /&gt;";
   
    $search_filter = '(&amp;(objectCategory=person)(samaccountname=*))';
    $attributes = array();
    $attributes[] = 'cn';
    $attributes[] = 'mail';
    $attributes[] = 'samaccountname';
    $attributes[] = 'sn';
    $result = ldap_search($ldapconn,$ldaptree,$search_filter) or die ("Error in search query: ".ldap_error($ldapconn));
    ldap_sort($ldapconn,$result,"cn");
    $data = ldap_get_entries($ldapconn, $result);
       

        // iterate over array and print data for each entry
        echo '&lt;h1&gt;Utenti&lt;/h1&gt;';
        for ($i=0; $i&lt;$data["count"]; $i++) {
            //echo "dn is: ". $data[$i]["dn"] ."&lt;br /&gt;";
            echo "User: ". $data[$i]["cn"][0] ."&lt;br /&gt;";
            if(isset($data[$i]["mail"][0])) {
                echo "Email: ". $data[$i]["mail"][0] ."&lt;br /&gt;&lt;br /&gt;";
            } else {
                echo "Email: None&lt;br /&gt;&lt;br /&gt;";
            }
        }
        // print number of entries found
        echo "Number of entries found: " . ldap_count_entries($ldapconn, $result);
    } else {
        echo "LDAP bind failed...";
    }
}

// all done? clean up
ldap_close($ldapconn);
?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/1260458</link><guid isPermaLink="true">https://dev.connect.gt/post/1260458</guid><dc:creator><![CDATA[linno]]></dc:creator><pubDate>Thu, 24 Oct 2019 10:08:39 GMT</pubDate></item></channel></rss>