20,398
社区成员




<?php
//
// phpCAS simple client
//
// import phpCAS lib
include_once('CAS.php');
//可以不用,用于调试,可以通过服务端的cas.log看到验证过程。
phpCAS::setDebug();
// initialize phpCAS
//phpCAS::client(CAS_VERSION_2_0,'服务地址',端口号,'cas的访问地址');
phpCAS::client(CAS_VERSION_2_0,'testsso.yigewang.com.cn',80,'');
// no SSL validation for the CAS server 不使用SSL服务校验
phpCAS::setNoCasServerValidation();
// force CAS authentication
//这里会检测服务器端的退出的通知,就能实现php和其他语言平台间同步登出了
phpCAS::handleLogoutRequests();
//phpCAS::checkAuthentication();
// 访问CAS的验证
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
// logout if desired
if (isset($_REQUEST['logout'])) {
$param=array("service"=>"http://localhost/phpCasClient/example_simple.php");//退出登录后返回
phpCAS::logout($param);
}
// for this test, simply print that the authentication was successfull
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!这是客户端1</h1>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>用户名:<?php echo phpCAS::getAttribute('USER_NAME'); ?>===</p>
<p><?php echo phpCAS::getAttribute('ORG_CODE'); ?>===</p>
<p>==<?php echo phpCAS::getAttribute('PER_CODE'); ?>===</p>
<p>==<?php echo phpCAS::getAttribute('EMAIL'); ?>===</p>
<p>==<?php echo phpCAS::getAttribute('MOBILE_NO'); ?>===</p>
<p>==<?php echo phpCAS::getAttribute('HEAD_PIC'); ?>===</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">退出</a></p>
</body>
</html>