# Match Radius.Class attributes

**URL:** <https://community.f5.com/t/match-radius-class-attributes/42528>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [March 15, 2013, 4:09pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528 "2013-03-15T16:09:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Archer](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jonathan\_Archer](https://community.f5.com/u/Jonathan_Archer)\
**Post date:** [March 15, 2013, 4:09pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/1 "2013-03-15T16:09:13Z")

</div>

We need to compare variables in the radius class attribute that are returned via an APM radius auth. The class attribute is stored in the APM in hex so I need to convert the hex to string.

I have tried

set e\_fields [split [mcget {session.radius.last.attr.class}] “|”];

set strAceServer [expr { [lindex $e\_fields 0] }];

set strAceServer [binary format c\* $strAceServer];

return $strAceServer;

and

set e\_fields [split [mcget {session.radius.last.attr.class}] “|”];

foreach field $e\_fields {

if ($field contains “\*ace\*”) {

return “YES”;

}

};

returns the hex

set e\_fields [split [mcget {session.radius.last.attr.class}] “|”];

return [expr { [lindex $e\_fields 0] }]

Any help would be appreciated to sort out the code.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Archer](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jonathan\_Archer](https://community.f5.com/u/Jonathan_Archer)\
**Post date:** [March 15, 2013, 4:10pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/2 "2013-03-15T16:10:16Z")

</div>

apm 11.2.0 hf3

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [March 16, 2013, 1:59am UTC](https://community.f5.com/t/match-radius-class-attributes/42528/3 "2013-03-16T01:59:00Z")

</div>

Try this:

```tcl
set e_fields [split [mcget {session.radius.last.attr.class}] "|"];
foreach field $e_fields { set hex [binary format H* [string range [string trim $fields] 2 end]];if { [string match -nocase "*ace*" $hex] } { return $hex } else { return "NO" }};

```

Three things:

1. The “contains” keyword is iRules-specific and doesn’t work in VPE rules.

2. You needed H\* for the binary format.

3. The hex value is stored with leading “0x” characters, but the binary format won’t work with this, so **[string range [string trim $fields] 2 end]]** gets rid of them.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 2, 2020, 9:53pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/4 "2020-06-02T21:53:32Z")

</div>

Hi Kevin,

The above is the irule or the reg exp on the VPE?

Thanks,

Reddy

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [June 3, 2020, 1:14pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/5 "2020-06-03T13:14:23Z")

</div>

This is the code inside the VPE agent.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 3, 2020, 7:35pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/6 "2020-06-03T19:35:39Z")

</div>

Thanks Kevin, Do i require to add the Message box within the VPE after the login and add this code?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [June 3, 2020, 7:37pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/7 "2020-06-03T19:37:34Z")

</div>

Message Box is a response to the client, so not expressly required.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 4, 2020, 2:56pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/8 "2020-06-04T14:56:03Z")

</div>

Thanks Kevin , Can i use the Logging as place holder for this code?

If not do you mind to help where i can add this code in the VPE?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [June 4, 2020, 3:02pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/9 "2020-06-04T15:02:35Z")

</div>

This code goes in a variable assignment agent. Create a session variable (ex. session.radius.last.attr.class.evaluated), then put the VPE code in the right side block. The code will populate the session variable with either the evaluated her value, or the string “NO”. You could insert a logging agent after this to send the variable to /var/log/apm (use %{variable} syntax in the logging agent), or you could send it back to the client in a message box agent. The logging agent is probably more practical.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 5, 2020, 12:41am UTC](https://community.f5.com/t/match-radius-class-attributes/42528/10 "2020-06-05T00:41:21Z")

</div>

Thanks much Kevin! Let me try and keep you posted.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 30, 2020, 3:19pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/11 "2020-06-30T15:19:52Z")

</div>

Hi Kevin,

i did implement as per your suggestion. When i checked the logs, i see the value being blank. I have attached the config.

---

<div class="post-metadata">

**Author:** ![Reddy1](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Reddy1](https://community.f5.com/u/Reddy1)\
**Post date:** [June 30, 2020, 3:20pm UTC](https://community.f5.com/t/match-radius-class-attributes/42528/12 "2020-06-30T15:20:43Z")

</div>

: Logging Agent: The Radius attribute :

I see the value shown as blank
