예제 #1
0
 function get_directory_people()
 {
     $filter = $this->build_dept_filter();
     if (empty($filter)) {
         $this->other_affiliation_flag = false;
     } else {
         $dir = new directory_service();
         $dir->search_by_filter($filter, $this->required_attributes);
         $records = $dir->get_records();
         if (!empty($records)) {
             $this->directory_people = $records;
             usort($this->directory_people, 'dir_result_last_name_sort');
         }
     }
 }
예제 #2
0
 function _get_email_addresses_from_users($users)
 {
     $usernames = array();
     foreach ($users as $user) {
         $usernames[] = $user->get_value('name');
     }
     $dir = new directory_service();
     $dir->search_by_attribute('ds_username', $usernames, array('ds_email'));
     $records = $dir->get_records();
     $emails = array();
     foreach ($records as $rec) {
         if (isset($rec['ds_username'][0]) && !empty($rec['ds_email'][0])) {
             $emails[$rec['ds_username'][0]] = $rec['ds_email'][0];
         }
     }
     asort($emails);
     return $emails;
 }
예제 #3
0
 /**
  * Returns directory service records ONLY for the authorized usernames field of a group.
  *
  * @param array optional array specifying which attributes are desired for the directory service records
  * @author Nathan White
  * @return array directory service records
  * @access public
  */
 function get_records_for_authorized_usernames_field($return_attr = array())
 {
     $authorized_usernames_block = $this->get_block_authorized_usernames();
     if (!empty($authorized_usernames_block)) {
         $filter = '(|' . $authorized_usernames_block . ')';
         $dir = new directory_service();
         $dir->search_by_filter($filter, $return_attr);
         $result = $dir->get_records();
         if (!empty($result)) {
             return $result;
         }
     }
     return false;
 }
$sites = $es->run_one();
$creator = id_of('ldap');
$report = '';
$report_head = "Synchronizing with directory...\n\n";
$dir = new directory_service();
foreach ($sites as $site) {
    $did_something = false;
    $report_section = '';
    $report_section .= "- " . $site->get_value('name') . "\n";
    // hit directory - get all faculty and staff, add them to the faculty staff type
    $dept = $site->get_value('department');
    // use the department from the site entity
    $filter = '(&(ou=' . $dept . ')(|(eduPersonPrimaryAffiliation=staff)(eduPersonPrimaryAffiliation=faculty)))';
    // this is the filter
    if ($dir->search_by_filter($filter, array('ds_username'))) {
        $fac_staff = $dir->get_records();
    } else {
        $fac_staff = array();
    }
    $netids = array();
    foreach ($fac_staff as $f) {
        $netids[] = $f['ds_username'][0];
    }
    $nes = new entity_selector($site->id());
    $nes->add_type(id_of('faculty_staff'));
    $reason_fac_staff = $nes->run_one();
    $reason_netids = array();
    $ldap_created = array();
    $reason_id = array();
    foreach ($reason_fac_staff as $f2) {
        $reason_netids[] = $f2->get_value('name');