Previous Topic: Responses and Response Attributes

Next Topic: Session Management

Retrieve Response Attributes

This sequence of calls retrieves the well-known attributes such as the user's distinguished name, the name of the directory associated with the user, and any text associated with the user's authentication. The online Agent API reference has a list of the well-known attributes that GetAttributes() can retrieve.

To retrieve response attributes

  1. Call the AgentUser methods Login() and GetResponse().
  2. With the AgentResponse object returned from GetResponse(), call GetAttributes().

Example: Retrieve the attributes for a response

The following script retrieves the attributes for a response to a user login request. The script then calls methods in the AgentResponseAttr object to display the attribute IDs, any attribute values, and other attribute information:

use Netegrity::AgentAPI;

$agentname="agent1";
$ip="127.0.0.1";
$sharedsecret="oursecret";
$username="userid";
$userpwd="userpwd";

$agentapi=Netegrity::AgentAPI‑>New($agentname,$sharedsecret);
#Add Policy Server configuration info...
$serverconfig = $agentapi‑>AddServerConfig($ip);
$agentapi‑>Connect();

$resource=$agentapi‑>GetResource("/mysite/hr/payroll.htm");
# Test whether the resource is protected. If it is,
# log in the user and get the attributes of the response.
if($resource‑>IsProtected() == SM_AGENTAPI_YES) {
   $user = $agentapi‑>CreateUser($username,$userpwd);
   print "\nLogging in user ".$user‑>Name()."...\n";
   $status=$user‑>Login($resource);
   if($status==SM_AGENTAPI_YES) {
      $response=$user‑>GetResponse();           
      @attr = $response‑>GetAttributes();
      foreach $attr(@attr) {
         print "\nAttribute ID = " . $attr‑>GetID()."\n";
         print "TTL = " . $attr‑>GetTTL()."\n";
         print "Value = " . $attr‑>GetValue()."\n";
         print "Name = " . $attr‑>GetName()."\n";
      }
   }
}
else {
   print "\nThe resource is not protected.\n\n";
}


Copyright © 2010 CA. All rights reserved. Email CA about this topic