/** * Get the new user information from the LDAP servers */ $active_dn = 'ou=People,dc=example,dc=net'; $inactive_dn = 'ou=Inactive Accounts,dc=example,dc=net'; $backend = new LDAP_Auth_Backend(); $search = $backend->getUserListing(); while ($entry = $search->shiftEntry()) { $uid = $entry->getValue('uid'); $dn = $entry->dn(); // if no email, skip completely $emails = $entry->get_value('mail', 'all'); if (!$emails) { echo "skip (no email): {$uid}, {$dn}\n"; continue; } // if ($uid != 'telvislightuploader') { // continue; // } $suffix = substr($dn, -strlen($inactive_dn)); if ($suffix == $inactive_dn) { echo "disabling: {$uid}, {$dn}\n"; $backend->disableAccount($uid); } $suffix = substr($dn, -strlen($active_dn)); if ($suffix == $active_dn) { $active = true; echo "updating: {$uid}, {$dn}\n"; $backend->updateLocalUserFromBackend($uid); } }