Example #1
0
 public static function post_login($parameters)
 {
     $uid = $parameters['uid'];
     $samlBackend = new OC_USER_SAML();
     if ($samlBackend->auth->isAuthenticated()) {
         $attributes = $samlBackend->auth->getAttributes();
         if (array_key_exists($samlBackend->usernameMapping, $attributes) && $attributes[$samlBackend->usernameMapping][0] == $uid) {
             $attributes = $samlBackend->auth->getAttributes();
             if (array_key_exists($samlBackend->mailMapping, $attributes)) {
                 $saml_email = $attributes[$samlBackend->mailMapping][0];
             }
             if (array_key_exists($samlBackend->groupMapping, $attributes)) {
                 $saml_groups = $attributes[$samlBackend->groupMapping];
             } else {
                 if (!empty($samlBackend->defaultGroup)) {
                     $saml_groups = array($samlBackend->defaultGroup);
                     OC_Log::write('saml', 'Using default group "' . $samlBackend->defaultGroup . '" for the user: '******'/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) {
                     OC_Log::write('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OC_Log::DEBUG);
                     return false;
                 } else {
                     $random_password = random_password();
                     OC_Log::write('saml', 'Creating new user: '******'saml', 'Updating data of the user: ' . $uid, OC_Log::DEBUG);
                     if (isset($saml_email)) {
                         update_mail($uid, $saml_email);
                     }
                     if (isset($saml_groups)) {
                         update_groups($uid, $saml_groups, $samlBackend->protectedGroups, false);
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
Example #2
0
 public static function update_user($uid, $attributes)
 {
     $casBackend = OC_USER_CAS::getInstance();
     \OCP\Util::writeLog('cas', 'Updating data of the user: '******'cas', 'attr: ' . implode(",", $attributes), \OCP\Util::DEBUG);
     if (isset($attributes['cas_email'])) {
         update_mail($uid, $attributes['cas_email']);
     }
     if (isset($attributes['cas_name'])) {
         update_name($uid, $attributes['cas_name']);
     }
     if (isset($attributes['cas_groups'])) {
         update_groups($uid, $attributes['cas_groups'], $casBackend->protectedGroups, false);
     }
 }
Example #3
0
 public static function post_login($parameters)
 {
     $uid = $parameters['uid'];
     $wuid = $uid;
     $casBackend = new OC_USER_CAS();
     $userDB = new OC_User_Database();
     /*
      * Récupération des données du fichier config général /config/config.php
      */
     $serveur_Search = OCP\Config::getSystemValue('serveur_Search', 'error');
     $port = OCP\Config::getSystemValue('port', 'error');
     $racineAMU = OCP\Config::getSystemValue('racineAMU', 'error');
     $racineAMUGRP = OCP\Config::getSystemValue('racineAMUGRP', 'error');
     $AMU_nuage_dn = OCP\Config::getSystemValue('AMU_nuage_dn', 'error');
     $AMU_nuage_pw = OCP\Config::getSystemValue('AMU_nuage_pw', 'error');
     $PQuota = OCP\Config::getSystemValue('PQuota', 'unManaged');
     $EQuota = OCP\Config::getSystemValue('EQuota', 'unManaged');
     $LDAP = new LDAP_Infos($serveur_Search, $AMU_nuage_dn, $AMU_nuage_pw, $racineAMUGRP, $racineAMUGRP);
     $restrictGrp = array("cn", "member");
     /*
      * Récupération tableau Groupes
      * Si le tableau 'groupMapping' est vide pas de contrôle sur les groupes
      */
     $AccesCloud = 0;
     OCP\Util::writeLog('user_cas', "Authentification (Mapping groups=" . $casBackend->groupMapping . ")", OCP\Util::DEBUG);
     if ($casBackend->groupMapping) {
         $wTabGrp = str_replace(array('<br>', '<br />', "\n", "\r"), array('@', '', '@', ''), $casBackend->groupMapping);
         $tabGRP = explode("@", $wTabGrp);
         $i = 0;
         $mesGroupes = array();
         foreach ($tabGRP as $key => $value) {
             $ListeMembre = $LDAP->getMembersOfGroup($value, $restrictGrp);
             if (in_array($uid, $ListeMembre)) {
                 $AccesCloudAMU = 1;
             }
         }
     } else {
         $AccesCloud = 1;
     }
     /*
      * Si pas d'acces, alors déconnexion
      */
     if ($AccesCloud == 0) {
         /*
          * On vérifie si le compte utilisé est un compte local
          */
         if (!$userDB->userExists($uid)) {
             OCP\Util::writeLog('user_cas', "Aucun droit d'accès pour l'utilisateur " . $uid, OCP\Util::ERROR);
             \OC_User::logout();
         } else {
             OCP\Util::writeLog('user_cas', "Authentification locale pour l'utilisateur " . $uid, OCP\Util::DEBUG);
             OC::$REQUESTEDAPP = '';
             OC_Util::redirectToDefaultPage();
             exit(0);
         }
     }
     /**
      * Récupère les groupes liés à l'utilisateur avec la racine définie dans le formulaire 'cas_group_root'
      * Si 'cas_group_root' n'est pas renseingé => pas de récupération de groupes
      */
     $mesGroupes = array();
     OCP\Util::writeLog('user_cas', "Authentification (Racine Groupes LDAP=" . $casBackend->groupRoot . ")", OCP\Util::DEBUG);
     if ($casBackend->groupRoot) {
         $i = 0;
         $ListeGRP = $LDAP->getMemberOf($uid);
         $a = sizeof($ListeGRP);
         OCP\Util::writeLog('user_cas', "Taille=" . $a . " UID=" . $uid, OCP\Util::ERROR);
         OCP\Util::writeLog('user_cas', "Racine Groupe=" . $casBackend->groupRoot, OCP\Util::ERROR);
         foreach ($ListeGRP as $key => $value) {
             if (strstr($value, $casBackend->groupRoot)) {
                 $mesGroupes[$i] = strtoupper(str_replace(':', '_', substr($value, 8)));
                 OCP\Util::writeLog('user_cas', "Groupe[{$i}]=" . $mesGroupes[$i], OCP\Util::ERROR);
                 $i++;
             }
         }
     }
     if (phpCAS::checkAuthentication()) {
         //$attributes = phpCAS::getAttributes();
         $cas_uid = phpCAS::getUser();
         if ($cas_uid == $uid) {
             /*
              * Récupération des information utilisateur (LDAP)
              */
             $tabLdapUser = $LDAP->getUserInfo($uid);
             if ($tabLdapUser) {
                 $DisplayName = $tabLdapUser['displayName'];
             }
             if (!$userDB->userExists($uid)) {
                 if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) {
                     OCP\Util::writeLog('cas', 'Utilisateur  invalide "' . $uid . '", caracteres autorises "a-zA-Z0-9" and "_.@-" ', OCP\Util::DEBUG);
                     return false;
                 } else {
                     /*
                      * Dans le cas d'une création
                      */
                     $random_password = \OC_Util::generateRandomBytes(20);
                     $userDB->createUser($uid, $tabLdapUser['userpassword']);
                     $userDB->setDisplayName($uid, $DisplayName);
                     /*
                      * Mise à jour du quota si gestion dans fichier de configuration
                      */
                     if ($EQuota != "unManaged" && $tabLdapUser['eduPersonPrimaryAffiliation'] == 'student') {
                         update_quota($uid, $EQuota);
                     }
                     if ($PQuota != "unManaged" && $tabLdapUser['eduPersonPrimaryAffiliation'] != 'student') {
                         update_quota($uid, $PQuota);
                     }
                 }
             }
             /*
              * Mise à jour des groupes associés
              */
             if (sizeof($mesGroupes) > 0) {
                 $cas_groups = $mesGroupes;
                 update_groups($uid, $cas_groups, $casBackend->protectedGroups, true);
             }
             /*
              * Mise à jour du mail
              */
             update_mail($uid, $tabLdapUser['Mail']);
             /*
              * Mise à jour du display name
              */
             $userDB->setDisplayName($uid, $DisplayName);
             return true;
         }
     }
     return false;
 }
Example #4
0
function update_user_data($uid, $attributes = array(), $just_created = false)
{
    OC_Util::setupFS($uid);
    OCP\Util::writeLog('saml', 'Updating data of the user: '******'email'])) {
        update_mail($uid, $attributes['email']);
    }
    if (isset($attributes['groups'])) {
        update_groups($uid, $attributes['groups'], $attributes['protected_groups'], $just_created);
    }
    if (isset($attributes['display_name'])) {
        update_display_name($uid, $attributes['display_name']);
    }
    if (isset($attributes['quota'])) {
        update_quota($uid, $attributes['quota']);
    }
}
Example #5
0
 public static function post_login($parameters)
 {
     $userid = $parameters['uid'];
     $samlBackend = new OC_USER_SAML();
     if ($samlBackend->auth->isAuthenticated()) {
         $attributes = $samlBackend->auth->getAttributes();
         $usernameFound = false;
         foreach ($samlBackend->usernameMapping as $usernameMapping) {
             if (array_key_exists($usernameMapping, $attributes) && !empty($attributes[$usernameMapping][0])) {
                 $usernameFound = true;
                 $uid = $attributes[$usernameMapping][0];
                 OC_Log::write('saml', 'Authenticated user ' . $uid, OC_Log::DEBUG);
                 break;
             }
         }
         if ($usernameFound && $uid == $userid) {
             $attributes = $samlBackend->auth->getAttributes();
             $saml_email = '';
             foreach ($samlBackend->mailMapping as $mailMapping) {
                 if (array_key_exists($mailMapping, $attributes) && !empty($attributes[$mailMapping][0])) {
                     $saml_email = $attributes[$mailMapping][0];
                     break;
                 }
             }
             $saml_display_name = '';
             foreach ($samlBackend->displayNameMapping as $displayNameMapping) {
                 if (array_key_exists($displayNameMapping, $attributes) && !empty($attributes[$displayNameMapping][0])) {
                     $saml_display_name = $attributes[$displayNameMapping][0];
                     break;
                 }
             }
             $saml_groups = array();
             foreach ($samlBackend->groupMapping as $groupMapping) {
                 if (array_key_exists($groupMapping, $attributes) && !empty($attributes[$groupMapping])) {
                     $saml_groups = array_merge($saml_groups, $attributes[$groupMapping]);
                 }
             }
             if (empty($saml_groups) && !empty($samlBackend->defaultGroup)) {
                 $saml_groups = array($samlBackend->defaultGroup);
                 OC_Log::write('saml', 'Using default group "' . $samlBackend->defaultGroup . '" for the user: '******'/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) {
                     OC_Log::write('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OC_Log::DEBUG);
                     return false;
                 } else {
                     $random_password = OC_Util::generate_random_bytes(20);
                     OC_Log::write('saml', 'Creating new user: '******'saml', 'Updating data of the user: ' . $uid, OC_Log::DEBUG);
                     if (isset($saml_email)) {
                         update_mail($uid, $saml_email);
                     }
                     if (isset($saml_groups)) {
                         update_groups($uid, $saml_groups, $samlBackend->protectedGroups, false);
                     }
                     if (isset($saml_display_name)) {
                         update_display_name($uid, $saml_display_name);
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
function Post_Process($ID, $Update = null, $Flag = null, $switch, $table = null, $Flag1 = null)
{
    //Table Array Holds the Fields and table name that Will be Updated
    $tables = array(2 => '_formulize_application_form_link/`appid`/linkid', 3 => '_formulize_application_form_link/`fid`/`linkid`', 4 => '_formulize/`id_form`/`ele_id`', 5 => '_formulize/`ele_value`/`ele_id`', 6 => '_formulize_framework_links/`fl_frame_id`/`fl_id`', 7 => '_formulize_framework_links/`fl_form1_id`/`fl_id`', 8 => '_formulize_framework_links/`fl_form2_id`/`fl_id`', 9 => '_formulize_framework_links/`fl_key1`/`fl_id`', 10 => '_formulize_framework_links/`fl_key2`/`fl_id`', 11 => '_formulize/`ele_display`/`ele_id`', 12 => '_formulize/`ele_disabled`/`ele_id`', 13 => '_formulize_id/`form_handle`/`id_form`', 14 => '_formulize/`ele_handle`/`ele_id`', 15 => '_formulize/`ele_filtersettings`/`ele_id`', 16 => '_formulize_entry_owner_groups/`groupid`/`owner_id`', 17 => '_formulize_entry_owner_groups/`fid`/`owner_id`', 18 => '_formulize_group_filters/`groupid`/`filterid`', 19 => '_formulize_group_filters/`fid`/`filterid`', 20 => '_formulize_group_filters/filter/filterid', 21 => '_formulize_groupscope_settings/`groupid`/`groupscope_id`', 22 => '_formulize_groupscope_settings/view_groupid/`groupscope_id`', 23 => '_formulize_groupscope_settings/fid/`groupscope_id`', 24 => '_group_lists/gl_groups/`gl_id`', 25 => '_formulize_advanced_calculations/fltr_grps/acid', 26 => '_formulize_advanced_calculations/fid/acid', 27 => '_formulize_other/ele_id/other_id', 28 => '_formulize_notification_conditions/not_cons_fid/not_cons_id', 29 => '_formulize_notification_conditions/not_cons_event/not_cons_id', 30 => '_formulize_notification_conditions/not_cons_groupid/not_cons_id', 31 => '_formulize_notification_conditions/not_cons_elementuids/not_cons_id', 32 => '_formulize_notification_conditions/not_cons_elementemail/not_cons_id', 33 => '_formulize_notification_conditions/not_cons_con/not_cons_id', 34 => '_formulize_saved_views/sv_pubgroups/sv_id/', 35 => '_formulize_saved_views/sv_owner_uid/sv_id/', 36 => '_formulize_saved_views/sv_mod_uid/sv_id/', 37 => '_formulize_saved_views/sv_formframe/sv_id/', 38 => '_formulize_saved_views/sv_mainform/sv_id/', 39 => '_formulize_saved_views/sv_calc_cols/sv_id/', 40 => '_formulize_saved_views/sv_oldcols/sv_id/', 41 => '_formulize_saved_views/sv_calc_grouping/sv_id/', 42 => '_formulize_screen/fid/sid', 43 => '_formulize_screen/frid/sid', 44 => '_formulize_screen_form/sid/formid', 45 => '_formulize_screen_multipage/sid/multipageid', 46 => '_formulize_screen_multipage/pages/multipageid', 47 => '_formulize_screen_multipage/conditions/multipageid', 48 => '_formulize_screen_multipage/paraentryform/multipageid', 50 => '_formulize_screen_listofentries/sid/listofentriesid', 51 => '_formulize_screen_listofentries/limitviews/listofentriesid', 52 => '_formulize_screen_listofentries/defaultview /listofentriesid', 53 => '_formulize_screen_listofentries/hiddencolumns/listofentriesid', 54 => '_formulize_screen_listofentries/decolumns/listofentriesid', 55 => '_formulize_screen_listofentries/viewentryscreen/listofentriesid', 56 => '_group_permission/gperm_itemid/gperm_id', 57 => '_group_permission/gperm_groupid/gperm_id');
    $fields = explode('/', $tables[$table]);
    $conn = new Connection();
    switch ($switch) {
        case 1:
            //Removed this Case statement Part and changed it to a more efficient one //Will Remove this Case and Update the Function Parameters in the next code Cleaning
            break;
        case 2:
            $sql = "UPDATE " . Prefix . "" . $fields[0] . " SET " . $fields[1] . "= :Update where " . $fields[2] . "= :id";
            $Query = $conn->connect()->prepare($sql);
            break;
        case 3:
            //This Is done because it's much easier to Get the Ele_Display/Ele_Disable from the DB after its inserted.Preg-match and Str_Pos won't be Reliable to get from Insert String
            foreach ($ID as $ElementID) {
                $result = get_result('_formulize', $ElementID);
                if ($result["{$Flag1}"] != '1' && $result["{$Flag1}"] != '0') {
                    $Flag1 == "ele_display" ? update_groups('_formulize', $ElementID, 3) : update_groups('_formulize', $ElementID, 4);
                }
            }
            break;
    }
    if ($Flag1 == null) {
        //This iF The Post Process In Case 2: Which is the General Update Fields  for any Field ,but the Ele_display needs to be returned Broken Down and Processed to check each Group
        $Query->bindValue(':Update', $Update);
        $Query->bindValue(':id', $ID);
        $Query->execute();
    }
}
Example #7
0
 $serverinfo = $ts3->serverInfo();
 if ($defchid != 0) {
     try {
         usleep($slowmode);
         $ts3->clientMove($whoami['client_id'], $defchid);
     } catch (Exception $e) {
     }
 }
 $jobid = log_mysql('calc_user', $mysqlcon);
 calc_user($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone, $showgen, $update, $grouptime, $boostarr, $resetbydbchange, $msgtouser, $uniqueid, $updateinfotime, $currvers, $substridle, $exceptuuid, $exceptgroup, $allclients);
 usleep($slowmode);
 $jobid = log_mysql('get_avatars', $mysqlcon);
 get_avatars($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone);
 usleep($slowmode);
 $jobid = log_mysql('update_groups', $mysqlcon);
 update_groups($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone, $serverinfo);
 usleep($slowmode);
 $jobid = log_mysql('calc_serverstats', $mysqlcon);
 calc_serverstats($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone, $serverinfo, $substridle, $grouptime);
 usleep($slowmode);
 $jobid = log_mysql('calc_userstats', $mysqlcon);
 calc_userstats($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone);
 usleep($slowmode);
 $jobid = log_mysql('clean', $mysqlcon);
 clean($ts3, $mysqlcon, $lang, $dbname, $slowmode, $jobid, $timezone, $cleanclients, $cleanperiod);
 usleep($slowmode);
 //check auf fehler in job_log
 if (!is_file(substr(__DIR__, 0, -4) . 'logs/pid')) {
     echo DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u "), "Received signal to stop. Shutting down...\n";
     exit;
 }
Example #8
0
if (!isset($_POST['submit'])) {
    $user = new User($_GET['memberid']);
    $cur_user = new User();
    $cur_user->userid = Auth::getCurrentID();
    if (!Auth::isAdmin() && !$cur_user->is_group_admin($user->get_groupids())) {
        CmnFns::do_error_box(translate('This is only accessable to the administrator'));
        die;
    }
    print_edit((bool) $_GET['edit'] && Auth::isAdmin(), $user);
} else {
    if (!Auth::isAdmin()) {
        CmnFns::do_error_box(translate('This is only accessable to the administrator'));
        die;
    }
    $to_add = isset($_POST['add_groups']) ? $_POST['add_groups'] : array();
    update_groups($_POST['memberid'], $to_add);
}
$t->endMain();
$t->printHTMLFooter();
/**
* Prints out the display/edit UI to add/remove groups for this user
* @param string $memberid id of the member to to change groups for
*/
function print_edit($edit, &$user)
{
    $group = new Group(new GroupDB());
    $non_user_groups = $group->getGroups($user->get_id());
    $user_groups = $user->groups;
    begin_table($user->get_name());
    if ($edit) {
        print_groups_to_add($non_user_groups);
    $u_obj =& $u_handler->get($uid);
}
if (!is_object($u_obj)) {
    redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MSG_UNEXPECTED_ERROR);
    exit;
}
foreach ($vals['xoops'] as $key => $val) {
    $u_obj->set($key, $val);
}
if (!$u_handler->insert($u_obj)) {
    redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MSG_UNEXPECTED_ERROR);
    exit;
}
$uid = $u_obj->getVar('uid', 'n');
// >> xoops group information
if (!update_groups($uid, $vals['groups']['groups'])) {
    redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MSG_UNEXPECTED_ERROR);
    exit;
}
// xoonips user information
if ($is_newuser) {
    if (!pickup_user($uid)) {
        redirect_header($xoonips_admin['mypage_url'], 3, _AM_XOONIPS_MSG_UNEXPECTED_ERROR);
        exit;
    }
}
$xu_handler =& xoonips_getormhandler('xoonips', 'users');
$xu_obj =& $xu_handler->get($uid);
foreach ($vals['xoonips'] as $key => $val) {
    $xu_obj->set($key, $val);
}