0 votes

We are using the below snippet to grab the email of a single custom attribute object.

Can I get guidance on the best way to modify this to get all the emails of each object in a multi-value custom attribute object?

$user = $Context.BindToObjectByDN("%adm-CustomAttributeObject15%")

try
{
    $userEmail = $user.Get("mail")    
}
catch
{
    $Context.LogMessage("The user specified in parameter 'MyParameter' has no email address. ", "Information")    
} 
ago by (660 points)

1 Answer

0 votes
ago by (14.9k points)
selected ago by
Best answer

Hello,

As far as we understand, you need to get the mail property value of each object specified in a custom object multi-valued property. If so, the below script can be used. It outputs the mail property value of each object to the execution log. In the script, the $propertyName variable specifies the name of a custom object multi-valued property.

$propertyName = "adm-CustomAttributeObjectMultiValue1" #TODO: 
modify me

# Get property values
try
{
    $userDNs = $Context.TargetObject.GetEx($propertyName)
}
catch
{
    # The property is not specified
    return
}

foreach ($dn in $userDNs)
{
    # Bind to a user
    $user = $Context.BindToObjectByDN($dn)

    try
    {
        # Get mail property value
        $userEmail = $user.Get("mail")
        $Context.LogMessage("Email address: $userEmail", "Information")
    }
    catch
    {
        $Context.LogMessage("The user " + $user.FullName + " has no email address", "Information")
    }
}

Related questions

0 votes
1 answer

We are wanting to display all values entered into a multi value text attribute in an email sent by Adaxes. What we've found is that only the first entry into the array ... Entry" Is there a way to reference the variable so that it displays all entries? Thanks

asked Dec 12 by msheppard (660 points)
0 votes
1 answer

Hello, i have created a custom attribute named user entry date. When a new user is created they need to enter the entry date with the create user command. The entry date ... buisness rule because it does not write any value in the sent email. Thank you, Fabian

asked Jun 7 by fabian.p (380 points)
0 votes
1 answer

Dear Is it possible to change the values of a custom attribute (adm-CustomAttributeTextMultiValue4) when selecting a value from another custom attribute (adm-CustomAttributeText1). For ... , 2Latijn, 3Latijn, etc... Is this possible? Sincerly Hilmi Emre Bayat

asked Aug 26, 2019 by hilmiemrebayat (120 points)
0 votes
1 answer

I am trying to find a way to get an hourly report on locked out user accounts to only be sent if the total amout of locked out account exceeds 10 users. Is this possible in ... a way to setup the logic to check to see how many items are returned in a report.

asked Jun 12 by Vertigo (50 points)
0 votes
1 answer

Is there a way to get the name of the user who approved a request and supply that to a step inside of a custom command? For example, HR submits a status change for an employee. ... and pass it as a param in a custom command that is called in one of the steps?

asked May 12, 2021 by davfount90 (20 points)
3,589 questions
3,278 answers
8,303 comments
548,115 users