Symantec Access Management

 View Only

Perl API: Returning Agent Group name from Realm

  • 1.  Perl API: Returning Agent Group name from Realm

    Broadcom Employee
    Posted Oct 16, 2017 09:17 PM

    GOPI-ADP asked how to return the Agent Group name from a Realm using the Perl API here:

     

    https://communities.ca.com/thread/2256268#comment-8016404 

     

    GetAgent will return either an Agent (Netegrity::PolicyMgtAgent) or an Agent Group (Netegrity::PolicyMgtGroup) object depending on what is set for the Realm. The name, either if it is an Agent or Agent Group will be returned by calling the Name() method on the object returned by the Agent() method called on the realm object.

     

    The code below will output:

     

    domain_name->realm_name->agent_or_agentgroup_name Type=Netegrity::PolicyMgtAgent|Netegrity::PolicyMgtGroup

     

    e.g.

     

    mydomain->all->agentgroup_mydomain Type=Netegrity::PolicyMgtGroup

    use Netegrity::PolicyMgtAPI;
    use Scalar::Util qw(blessed);

    $policyapi = Netegrity::PolicyMgtAPI->New();
    $session = $policyapi->CreateSession("<ADMINUSER>", "<ADMINPWD>");
    die "\nFATAL: Cannot create session. Please check admin credentials\n" unless ($session != undef);
    $domain = $session->GetDomain("<DOMAIN>");
    print $domain->Name(), "->";
    $realm = $domain->GetRealm("<REALM>");
    print $realm->Name(), "->";
    $agent = $realm->Agent();
    print $agent->Name(), " Type=";
    print blessed($agent)