123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- require_once(api_get_path(SYS_PATH).'main/auth/cas/cas_var.inc.php');
- require_once(api_get_path(SYS_PATH).'main/auth/ldap/authldap.php');
- function cas_is_authenticated()
- {
- global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
- global $PHPCAS_CLIENT;
- global $logout;
- if (!is_object($PHPCAS_CLIENT) )
- {
- phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
- phpCAS::setNoCasServerValidation();
- }
- $auth = phpCAS::checkAuthentication();
-
- if ($auth) {
- $login= trim(phpCAS::getUser());
-
-
-
- if (! $logout){
- $user_table = Database::get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT user_id, username, password, auth_source, active, expiration_date ".
- "FROM $user_table ".
- "WHERE username = '$login' ";
- $result = api_sql_query($sql,__FILE__,__LINE__);
- if(mysql_num_rows($result) == 0) {
- require_once(api_get_path(SYS_PATH).'main/inc/lib/usermanager.lib.php');
- $rnumber=rand(0,256000);
- UserManager::create_user($firstName, $lastName, $status, $email, $login, md5('casplaceholder'.$rnumber), $official_code='',$language='',$phone='',$picture_uri='',$auth_source = PLATFORM_AUTH_SOURCE);
- }
- else {
- $user = mysql_fetch_assoc($result);
- $user_id = intval($user['user_id']);
-
- UserManager::update_user ($user_id, $firstname, $lastname, $login, null, null, $email, $status, '', '', '', '', 1, null, 0, null,'') ;
- }
- }
- return($login);
- }
- else
- {
- return(false);
- }
- }
-
- function cas_logout()
- {
-
-
- phpCAS::logoutWithRedirectService(api_get_path(WEB_PATH));
- }
- ?>
|