Guest User

Untitled

a guest
Apr 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. //Conexao com AD
  4. $ldapconfig['host']= '192.168.203.5'; //AD-001
  5. $ldapconfig['port']= '389'; //Porta Padrão
  6. $ldapconfig['dn'] = "";
  7. $domain= 'peccin.local';
  8. $username = 'diego.venuzka';
  9. $password = 'xxxxxxx';
  10.  
  11. //Faz conexão com AD usando LDAP
  12. $sn= ldap_connect($ldapconfig['host'], $ldapconfig['port']);
  13. ldap_set_option($sn, LDAP_OPT_PROTOCOL_VERSION, 3);
  14. ldap_set_option($sn, LDAP_OPT_REFERRALS, 0);
  15.  
  16. @$bind=ldap_bind($sn, $username .'@'.$domain, $password);
  17.  
  18.  
  19. $filter = "(sAMAccountName=carlo*)";
  20. $attributes = array('name');
  21. $search = ldap_search($sn,'DC=peccin, DC=local', $filter, $attributes);
  22.  
  23. $data = ldap_get_entries($sn, $search);
  24.  
  25. foreach ($data AS $key => $value){
  26.  
  27. echo @$value["name"][0]."<br>";
  28.  
  29. }
  30.  
  31. ?>
Add Comment
Please, Sign In to add comment