Hi this script was usefull to me:

I know there can be changes due to updated version of phpCAS.

Regards Manfredo

<?php

//initialize the CAS library
require_once('auth/cas/CAS/CAS.php');
$_REQUEST['login'] = 'uday';
phpCAS::client(CAS_VERSION_2_0, 'server.name', 8444,'/cas');

phpCAS::setDebug($filename='phpCAS.log');
phpCAS::traceBegin();
phpCAS::setCasServerCACert('/xxx/yyy/cert.pem'); /
//phpCAS::setNoCasServerValidation();

//if the user is requesting to be logged in
if (isset($_REQUEST['login'])) {
   phpCAS::forceAuthentication();
   //the user is known to be logged in to CAS at this point
   $_SESSION['loggedInLocally'] = TRUE;  //set a local variable telling the
program we are logged in
   $_SESSION['username'] = phpCAS::getUser();  //this stores their network
user id

}

//if we want to log out of the program
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
   $_SESSION['loggedInLocally'] = false;
   unset($_SESSION['username']);
}

if (isset($_SESSION['loggedInLocally']) &&
$_SESSION['loggedInLocally']===true) {
echo "You are logged in to the application";
} else {
   echo "You are not logged in to the application.  Log in by specifying
the 'login' log parameter to this script.";
}

phpCAS::traceEnd();

?>

<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<?php require 'script_info.php' ?>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>


2015-09-23 8:24 GMT-03:00 Guillaume Chéramy <[email protected]>:

> Hello,
>
>    I search and try lots of configuration and I have no results.
>
> I want to provide ldap attributes from CAS I have defined
> ldapPersonAttributeDao in deployerConfigContext.xml :
>
> <bean id="ldapPersonAttributeDao"
>
>
> class="org.jasig.services.persondir.support.ldap.LdaptivePersonAttributeDao"
>       p:connectionFactory-ref="searchPooledLdapConnectionFactory"
>       p:baseDN="${ldap.baseDn}"
>       p:searchControls-ref="searchControls"
>       p:searchFilter="uid={0}">
>     <property name="resultAttributeMapping">
>         <map>
>             <!--
>                | Key is LDAP attribute name, value is principal
> attribute name.
>                -->
>             <entry key="uid" value="uid" />
>             <entry key="mail" value="mail" />
>         </map>
>     </property>
> </bean>
>
> <bean id="searchControls"
>       class="javax.naming.directory.SearchControls"
>       p:searchScope="2"
>       p:countLimit="10" />
>
>
> I have no restriction in my service json :
>
> {
>   "@class" : "org.jasig.cas.services.RegexRegisteredService",
>   "serviceId" : "^https://phptestcas.domaine.com/.*";,
>   "name" : "phptestcas",
>   "id" : 10000003,
>   "description" : "Authorization for testing application phptestcas.",
>   "proxyPolicy" : {
>     "@class" : "org.jasig.cas.services.RefuseRegisteredServiceProxyPolicy"
>   },
>   "evaluationOrder" : 0,
>   "usernameAttributeProvider" : {
>     "@class" :
> "org.jasig.cas.services.DefaultRegisteredServiceUsernameProvider"
>   },
>   "logoutType" : "BACK_CHANNEL",
>   "accessStrategy" : {
>     "@class" :
> "org.jasig.cas.services.DefaultRegisteredServiceAccessStrategy",
>     "enabled" : true,
>     "ssoEnabled" : true
>   }
> }
>
> But when I try a with phpcas to get attributes :
> <p>uid : <b><?php echo phpCAS::getAttribute('uid'); ?></b>.</p>
> <p>mail : <b><?php echo phpCAS::getAttribute('mail'); ?></b>.</p>
>
> I have no results.
>
> What I missing ?
>
> Sincerely
>
> guidtz
>
> --
> You are currently subscribed to [email protected] as:
> [email protected]
> To unsubscribe, change settings or access archives, see
> http://www.ja-sig.org/wiki/display/JSG/cas-user
>

-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

Reply via email to