function create_group() { $ldap = new clladp(); $tpl = new templates(); $sock = new sockets(); $page = CurrentPageName(); $q = new mysql(); $sql = "SELECT * FROM register_orgs WHERE `zmd5`='{$_GET["key"]}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); $ou = $ligne["ou"]; if ($ligne["ou"] == null) { echo $tpl->_ENGINE_parse_body("{please_register_first}"); return; } $domain = $ligne["domain"]; $user = $ligne["username"]; $password = $ligne["password"]; $gp = new groups(); if (!$gp->add_new_group("administrators", $ou)) { $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-red.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{group}: administrators {failed} {$gp->ldap_error}</td>\n\t\t</tr>\n\t\t</table>"; echo $tpl->_ENGINE_parse_body($html); return; } $update_array = array(); $values[] = "[AllowEditOuSecurity]=\"yes\""; $values[] = "[AsOrgPostfixAdministrator]=\"yes\""; $values[] = "[AsQuarantineAdministrator]=\"yes\""; $values[] = "[AsOrgStorageAdministrator]=\"yes\""; $values[] = "[AsMessagingOrg]=\"yes\""; $values[] = "[AsOrgAdmin]=\"yes\""; $gppid = $gp->GroupIDFromName($ou, "administrators"); $gp = new groups($gppid); $update_array["ArticaGroupPrivileges"][0] = @implode("\n", $values); $ldap->Ldap_modify($gp->dn, $update_array); if ($ldap->ldap_last_error != null) { $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-red.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{group}: administrators ({$gppid}) {permissions} {failed} {$ldap->ldap_last_error}</td>\n\t\t</tr>\n\t\t</table>"; echo $tpl->_ENGINE_parse_body($html); return; } $EnableVirtualDomainsInMailBoxes = $sock->GET_INFO("EnableVirtualDomainsInMailBoxes"); $uid = $user; if ($EnableVirtualDomainsInMailBoxes == 1) { $uid = "{$user}@{$domain}"; } if (!$gp->AddUsertoThisGroup($uid)) { $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-red.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{group}: administrators ({$gppid}) {affect} {$uid} {$ldap->ldap_last_error}</td>\n\t\t</tr>\n\t\t</table>"; echo $tpl->_ENGINE_parse_body($html); return; } $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-green.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{group}: administrators » {$uid} {success}</td>\n\t\t</tr>\n\t\t</table>\n\t\t<div id='step-5'></div>\n\t\t<script>\n\t\t\tLoadAjax('step-5','{$page}?create-groupwares=yes&key={$_GET["key"]}');\n\t\t</script>\t\t\n\t\t"; echo $tpl->_ENGINE_parse_body($html); return; }
function COMPUTER_ADD_TO_GROUP() { $dn = $_GET["add_computer_to_group"]; $gpid = $_GET["gpid"]; $uid = $_GET["uid"]; writelogs("Adding {$dn} in group {$gpid}"); $group = new groups($gpid); $group->AddUsertoThisGroup($uid); }
function USER_CHANGE_UID_SAVE() { $uid = $_GET["changeuidFrom"]; $uidnext = $_GET["changeuidTo"]; $user = new user($uid); $array["uid"][0] = $uidnext; $ldap = new clladp(); if (!$ldap->Ldap_modify($user->dn, $array)) { echo $ldap->ldap_last_error; exit; } $groups = $user->GetGroups($uid); $hash = $user->Groups_list($uid); if (is_array($hash)) { while (list($num, $val) = each($hash)) { $group = new groups($num); writelogs("Delete user ({$uid}) from {$val}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__); $group->DeleteUserFromThisGroup($uid); $group->AddUsertoThisGroup($uidnext); } } $users = new usersMenus(); if ($users->POSTFIX_INSTALLED) { $sock = new sockets(); $sock->getFrameWork("cmd.php?postfix-hash-aliases=yes"); } }
function USER_TO_GROUP($value) { include_once dirname(__FILE__) . '/ressources/class.user.inc'; include_once dirname(__FILE__) . '/ressources/class.groups.inc'; $array = unserialize(base64_decode($value)); if (!is_array($array)) { send_email_events("Failed to link user to group, not an array", "", "CLOUD"); return true; } $guid = $array["guid"]; $ou = $array["ou"]; $uid = $array["uid"]; events("Get group {$guid} informations {$ou}/{$uid}", __FUNCTION__, __FILE__, __LINE__); $group = new groups($guid); if ($group->AddUsertoThisGroup($uid)) { send_email_events("Success to link user {$uid} to group {$guid}", "", "CLOUD"); } else { send_email_events("Failed to link user {$uid} to group {$guid}", "", "CLOUD"); } sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.artica.meta.users.php --user \"{$uid}\""); return true; }
function popup_add() { $uid = base64_decode($_GET["add_already_member_add"]); $group = new groups($_GET["gpid"]); $group->AddUsertoThisGroup($uid); }
function import($ou, $path) { $usersM = new usersMenus(); $unix = new unix(); if (!is_file($path)) { echo "{$path}, no such file\n"; die; } $ldap = new clladp(); $oudn = "ou={$ou},dc=organizations,{$ldap->suffix}"; if (!$ldap->ExistsDN($oudn)) { $ldap->AddOrganization($ou); } $tmpfile = $unix->FILE_TEMP(); uncompress($path, $tmpfile); $datas = unserialize(base64_decode(@file_get_contents($tmpfile))); if (!is_array($datas)) { if ($GLOBALS["VERBOSE"]) { echo "Unable to import {$ou} {$path}, no such array\n"; return; } $unix->send_email_events(basename(__FILE__) . "::Unable to import {$ou} {$path}, no such array", null, "import"); die; } $usersArray = $datas["USERS"]; $groupsArray = $datas["GROUPS"]; unset($datas); echo "Creating groups in `{$ou}`"; while (list($num, $hash) = each($groupsArray)) { $ORG_GID = $hash["main_array"]["gid"]; $gp = new groups(); $gpid = $gp->GroupIDFromName($ou, $hash["groupName"]); if (!is_numeric($gpid)) { $gp->groupName = $hash["groupName"]; $gp->add_new_group($hash["groupName"], $ou); $gpid = $gp->GroupIDFromName($ou, $hash["groupName"]); } $gp = new groups($gpid); $members = $hash["members"]; while (list($a, $b) = each($members)) { echo "Insert {$b} user to {$hash["groupName"]}/{$gpid}\n"; $gp->AddUsertoThisGroup($b); } $gp->saveDescription($hash["main_array"]["description"]); $gp->ArticaGroupPrivileges = $hash["main_array"]["ArticaGroupPrivileges"]; $gp->Privileges_array = $hash["Privileges_array"]; $gp->SavePrivileges(); $GROUPSORGS[$ORG_GID] = $gpid; } while (list($num, $hash) = each($usersArray)) { $array_groups = $hash["array_groups"]; unset($hash["dn"]); unset($hash["UserExists"]); unset($hash["ou"]); unset($hash["local_sid"]); unset($hash["objectClass_array"]); unset($hash["group_id"]); unset($hash["sambaPrimaryGroupSID"]); unset($hash["accountGroup"]); unset($hash["uidNumber"]); unset($hash["sambaSID"]); unset($hash["sambaPrimaryGroupGID"]); unset($hash["gidNumber_array"]); $samba_groups = $hash["samba_groups"]; unset($hash["ldapClass"]); unset($hash["attributs_array"]); unset($hash["samba_groups"]); $users = new user($hash["uid"]); $users->ou = $ou; $users->group_id = $GROUPSORGS[$array_groups[0]]; while (list($a, $orgd) = each($hash)) { $users->a = $orgd; } $users->add_user(); if ($usersM->SAMBA_INSTALLED) { if (!$hash["NotASambaUser"]) { $users->Samba_edit_user(); } } } }