function AddNewComputerGroup() { $group = new groups(); if (!$group->add_new_group($_GET["AddNewComputerGroup"])) { echo $group->ldap_error; return; } $gpid = $group->GroupIDFromName(null, $_GET["AddNewComputerGroup"]); $group = new groups($gpid); $group->TransformGroupToSmbGroup(); }
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 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(); } } } }