Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Conexao com AD
- $ldapconfig['host']= '192.168.203.5'; //AD-001
- $ldapconfig['port']= '389'; //Porta Padrão
- $ldapconfig['dn'] = "";
- $domain= 'peccin.local';
- $username = 'diego.venuzka';
- $password = 'xxxxxxx';
- //Faz conexão com AD usando LDAP
- $sn= ldap_connect($ldapconfig['host'], $ldapconfig['port']);
- ldap_set_option($sn, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($sn, LDAP_OPT_REFERRALS, 0);
- @$bind=ldap_bind($sn, $username .'@'.$domain, $password);
- $filter = "(sAMAccountName=carlo*)";
- $attributes = array('name');
- $search = ldap_search($sn,'DC=peccin, DC=local', $filter, $attributes);
- $data = ldap_get_entries($sn, $search);
- foreach ($data AS $key => $value){
- echo @$value["name"][0]."<br>";
- }
- ?>
Add Comment
Please, Sign In to add comment