diff --git a/lib/adLDAP/classes/adLDAPGroups.php b/lib/adLDAP/classes/adLDAPGroups.php index 5faa9c1..71830aa 100644 --- a/lib/adLDAP/classes/adLDAPGroups.php +++ b/lib/adLDAP/classes/adLDAPGroups.php @@ -298,6 +298,32 @@ public function removeUser($group, $user, $isGUID = false) { } return true; } + + /** + * Remove all users from a group + * + * @param string $group The group to remove users from + * @return bool + */ + public function removeAllUsers($group) { + // Find parent and user distinguished names + $groupInfo = $this->info($group, array("member")); + if ($groupInfo[0]["dn"] === NULL || $groupInfo[0]["member"] === NULL) { + return false; + } + + $groupDn = $groupInfo[0]["dn"]; + + unset($groupInfo[0]['member']['count']); + + foreach ($groupInfo[0]["member"] as $member) { + $result = @ldap_mod_del($this->adldap->getLdapConnection(), $groupDn, array('member'=>$member)); + if ($result == false) { + return false; + } + } + return true; + } /** * Remove a contact from a group