Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("Content-type: text/plain");
- header("Content-Disposition: attachment; filename=seznam_mailboxu.csv");
- $ldap_server = 'ldap://pdcsrvdnc01.xxxx.cz';
- $auth_user = 'ldap';
- $auth_pass = 'xxxx';
- $base_dn = "OU=Uživatelé,DC=xxxx,DC=cz";
- $filter = "(&(objectClass=user)(kerio-Mail-AccountEnabled=1))";
- if (!($connect = ldap_connect ($ldap_server))) {
- die("Could not connect to ldap server");
- }
- if (!($bind = ldap_bind ($connect, $auth_user . '@xxxx.cz', $auth_pass))) {
- die('Unable to bind to server.');
- }
- if (!($search = ldap_search ($connect, $base_dn, $filter))) {
- die("Unable to search ldap server");
- }
- $number_returned = ldap_count_entries ($connect, $search);
- $info = ldap_get_entries ($connect, $search);
- for ($i=0; $i<$number_returned; $i++) {
- $name = strtr(strtr($info[$i]['cn'][0], ' ', '-'), 'áäčďéěëíµňôóöŕřšťúůüýžÁÄČĎÉĚËÍĄŇÓÖÔŘŔŠŤÚŮÜÝŽ', 'aacdeeeilnooorrstuuuyzaacdeeelinooorrstuuuyz');
- $n .= $info[$i]['cn'][0]. ';';
- for ($j=0; $j<count($info[$i]['member']); $j++) {
- $arr = explode(',', $info[$i]['member'][$j]);
- $n .= substr($arr[0], 3);
- }
- $n .= $info[$i]['l'][0]. ';';
- $n .= $info[$i]['samaccountname'][0]. '@xxxx.cz;';
- // zalomit radek
- }
- echo $n;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement