public function revoke($dn, $property) { $ldapObj = new Lucid_LDAP($this->configFile); if ($property === "VPN") { $attrib = $ldapObj->VPN; } if ($property === "SSH") { $attrib = $ldapObj->SSH; } if (!isset($attrib)) { throw new Exception("Invalid Property {$property}"); } $ldapObj->bind($this->username, $this->password); $status = $ldapObj->delAttribute($dn, $attrib); $ldapObj->destroy(); if ($status === true) { $this->loggerObj->log("ADMIN::info::{$this->username} has removed {$attrib} for {$dn} successfully"); } else { $this->loggerObj->log("ADMIN::error::{$this->username}'s Attempt to remove {$attrib} for {$dn} has failed. Reason: {$status}"); } return $status; }
public function updateTeams($username, $new) { $ldapObj = new Lucid_LDAP($this->configFile); $ldapObj->bind($this->username, $this->password); list($entry, $dn) = $ldapObj->searchUser($username, array("memberOf")); $allGroups = $ldapObj->getAllValues($entry, "memberOf"); $allTeams = array_values(array_filter($allGroups, function ($group) { $teamsDn = getConfig("baseGroupDn"); return preg_match("/{$teamsDn}/i", $group); })); $toDelete = array_values(array_diff($allTeams, $new)); $toAdd = array_values(array_diff($new, $allTeams)); if (count($toDelete) > 0) { for ($i = 0; $i < count($toDelete); $i++) { $status = $ldapObj->delAttribute($toDelete[$i], 'member', $dn); $this->loggerObj->log("ADMIN::info::{$this->username} has successfully removed {$username} from '{$toDelete[$i]}' Group"); } } if (count($toAdd) > 0) { $status = $this->addUserToGroups($ldapObj, $dn, $toAdd); } $ldapObj->destroy(); return True; }