How to get the value of an object

Hi
(different uses of the word “object” coming up!)
Using the “Get Object Properties” activity within the UiPath Active Directory Activities, I am trying to extract the “proxyAddresses” attribute for a user in AD. Variable type assigned as Object and it seems to get the property fine. (variable is UserProxyAddresses)

I try to display this in a log file (UserProxyAddresses.ToString) and all i get is “system.object

So this suggests to me that the variable is actually an array of objects… am I correct? However, if I try to handle as an array I’m just getting errors as well.

Please, tell me how I get the actual values to display.

Hi @brian.treadgold

Welcome to UiPath,

Yes, userproxyaddresses is an object holding string array.
use assign:
proxylist = directcast(userproxyaddresses, ienumerable).cast(of string).toarray

then use writeline:
string.join(“,”, proxylist)

this will show all proxyaddresses in log.

If you found helpful, Mark as a solution tick .
Happy Automation

Thank you! I can make sense of that now. I’ve managed to grab them separately and iterate through etc. Exactly what I was looking for.

Ah, not 100% solved - the assign is failing if there’s only one entry in the proxyaddresses field…

Hi @brian.treadgold,

Welcome to the Community!

  • The proxyAddresses attribute can return:
    • A single string (if only one address exists).
    • An array of strings (if multiple addresses exist).
  • UiPath treats both as Object, so you need to check the runtime type before casting.

Always type check before casting…

Use an If activity to check the runtime type of UserProxyAddresses :

If TypeOf UserProxyAddresses Is String Then
    proxylist = {UserProxyAddresses.ToString}
ElseIf TypeOf UserProxyAddresses Is IEnumerable Then
    proxylist = DirectCast(UserProxyAddresses, IEnumerable).Cast(Of String).ToArray
Else
    proxylist = {}
End If

This ensures:

  • Single string → wrapped in array.
  • Multiple strings → cast safely.
  • Unexpected type → fallback to empty array.

Then display value using log message or write line activity:
String.Join(“,”, proxylist)

Please try this step and let us know your result.
If this solves your issue, kindly mark it as solution to close the case.

Happy Automation😊

1 Like

Ok then

Use this in assign:

proxylist = If(TypeOf userproxyaddresses Is String, {userproxyaddresses.ToString}, DirectCast(userproxyaddresses, IEnumerable).Cast(Of String).ToArray)

It handles both single and multiple values.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.