title: How can i get manager name from AD in php?
body: <p>Now, i'm doing to connect my website to AD use ldap and get data from user logon but my problem is when user logon and i need to get manager name of user i get manager name by call <code>$entries[0]["manager"][0]</code> it's show data like this <code>CN=rosie,OU=AllUser,DC=xyz,DC=local</code> i need to get only manager name that is 'rosie' but i don't know to get it, please help</p>
  
  <p>this my code</p>
  
  <pre><code>$ldap_host ="servername";
  $ldap_port = "port";
  $ldap_dn = "OU=AllUser,DC=abc,DC=local";
  $ldap_usr_dom = '@abc.local';
  $ldap_it_group = "IT";
  $ldap = ldap_connect($ldap_host,$ldap_port) or die("Could not connect to ".$ldap_host);
  $bind = @ldap_bind($ldap, $user.$ldap_usr_dom, $password) or die("cant bind");
  if($bind) {
      $filter = "(&amp;(objectClass=*)(sAMAccountName=".$user."))";
      $attr = array("manager");
      $result = ldap_search($ldap, $ldap_dn, $filter, $attr) or exit("Unable to search LDAP server");
      $entries = ldap_get_entries($ldap, $result);
      ldap_unbind($ldap);
      for ($i=0; $i&lt;$entries["count"]; $i++) {
          echo "Manager is: ". $entries[0]["manager"][0]."&lt;p&gt;";
      }
  </code></pre>