You can try this in IRD.
1. Choose Statistical type and choose TargetState in function object.
2. Choose agent, agent name and stat server in the TargetState.
3. Debug and see the result.
4. It might give you the DN name & details in which the agent is logged in.
5. Then manipulate the result string to retrieve the DN name from the result.