PHP LDAP showing blank screen -


whats wrong code below? have changed domain , server name etc. privacy reasons.

the code shows blank page when should show @ least var dumps?

<?php  if(isset($_server['auth_user']) && isset($_server['auth_password'])){      $adserver = "ldap://ourserver";      $ldap = ldap_connect($adserver);     $username = $_server['auth_user'];     $password = $_server['auth_password'];     $shortname = explode('\\', $_server['auth_user']));      ldap_set_option($ldap, ldap_opt_protocol_version, 3);     ldap_set_option($ldap, ldap_opt_referrals, 0);      $bind = @ldap_bind($ldap, $username, $password);       if ($bind) {         $filter="(samaccountname=$shortname)";         $result = ldap_search($ldap,"dc=ourdomain,dc=local",$filter);         ldap_sort($ldap,$result,"sn");         $info = ldap_get_entries($ldap, $result);         ($i=0; $i<$info["count"]; $i++)         {             if($info['count'] > 1)                 break;             echo "<p>you accessing <strong> ". $info[$i]["sn"][0] .", " . $info[$i]["givenname"][0] ."</strong><br /> (" . $info[$i]["samaccountname"][0] .")</p>\n";             echo '<pre>';             //var_dump($info);             var_dump($_server);             echo '</pre>';             $userdn = $info[$i]["distinguishedname"][0];          }         @ldap_close($ldap);     } else {         $msg = "invalid credentials. more information please contact phonenumber.";         echo $msg;     }  }else{ ?>     <form action="#" method="post">         <label for="username">username: </label><input id="username" type="text" name="username" />          <label for="password">password: </label><input id="password" type="password" name="password" />        <input type="submit" name="submit" value="submit" />     </form> <?php } ?>  

i've worked out fix:

changes line 10 follows: $shortname = explode('\', $_server['auth_user']);

and line 19: $filter="(samaccountname=$shortname[1])";


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -