function _get_active_users_from_ids($ids, $affiliations)
 {
     @array_walk($ids, 'addslashes');
     $es = new entity_selector();
     $es->add_type(id_of('user'));
     $es->enable_multivalue_results();
     $es->add_relation('`entity`.`id` IN ("' . implode('","', $ids) . '")');
     $es->add_right_relationship_field('site_to_user', 'entity', 'id', 'site_membership_id');
     // This is here so we only grab users who have access to a site
     $users = $es->run_one();
     if (!empty($affiliations)) {
         // Construct a directory service ldap filter query to only include the possible users.
         $dir = new directory_service();
         $filter = $this->_get_ldap_filter($affiliations, $users);
         $dir->search_by_filter($filter);
         $dir_results = $dir->get_records();
         $users = $this->_get_users($users, array_keys($dir_results));
     }
     return $users;
 }
 /**
  * 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;
 }
$es->add_relation('site.department != ""');
$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) {
Exemple #4
0
<pre>
<?php 
/**
 * A little tester for trying out directory service functionality
 *
 * @todo build a more complete unit tester for directory services so that
 *       people developing them can make sure thay got it right
 *
 * @package carl_util
 * @subpackage dir_service
 */
/**
 * include the directory service
 */
include_once 'directory.php';
/**
 * Test things out
 */
$dir = new directory_service(array('mysql'));
$dir->search_by_filter('(|(&(a=b)(c=*d)(!(j~=k)))(ds_email=*g*)(h>=i))');
//$dir->search_by_attribute('ds_email', array('*****@*****.**','*****@*****.**'), array('ds_fullname'));
//echo $dir->get_first_value('ds_fullname');
//print_r($dir->get_records());
?>
</pre>
 function look_up_dir_reason_diffs()
 {
     // these are the people in Reason but not in the directory
     $to_lookup = array_diff(array_keys($this->reason_netids), array_keys($this->directory_netids));
     // get LDAP info for those people
     foreach ($to_lookup as $username) {
         $dir = new directory_service();
         $filter = $this->build_person_filter($username);
         if ($dir->search_by_filter($filter, $this->required_attributes)) {
             $this->reason_people_dir_info[$username] = $dir->get_first_record();
         }
     }
 }