0 votes

Hi

I've added values to two attributes of an Oraganization Unit:
adm-CustomAttributeText1
adm-CustomAttributeText2

I'm trying to extract these properties with a powershell script (this is to update the users email address based on a parent OU i a managed domain):

Import-Module Adaxes

$username = "user@domain.com"
$password = "password"
$domain = "domain.com"
$passwordSecure = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $passwordSecure)
$User="CN=%fullname%,OU=Users,OU=%extensionAttribute1%,DC=domain,DC=com"
$email=Get-AdmObject -Credential $credential -Server $domain -Identity 'OU=%extensionAttribute1%,DC=domain,DC=com' | FL adm-CustomAttributeText1

Set-AdmUser -Identity $User -Credential $credential -EmailAddress %firstname%.%lastname%@$email -Server $domain

But this does not provide the value set in adm-CustomAttributeText1.

Any ideas?

by (960 points)
0

Hello,

Can you describe in more detail what should the script do?

Also, are you trying to launch the script from Adaxes (with a Business Rule, Custom Command or Scheduled Task) or from the PowerShell console?

0

We are testing to see if Adaxes can be used in a multi-tennant solution. Therefore we want the user creation part to be "idiot-proof".

The script is put in a Business rule that launches after the user has been created. The script should then read the property adm-customAttributeText1 from the Customername ou (the user is created under Doman.local\Hosting\Customername\Users), and update the users email address to be %firstname%.%lastname%@ + the value of adm-customAttributeText1.

1 Answer

0 votes
by (215k points)
selected by
Best answer

Here's the script that matches your requirements:

$ouDN = "OU=%extensionAttribute1%,DC=domain,DC=com" # TODO: modify me

# TODO: bind to the OU
try
{
    $ou = $Context.BindToObjectByDN($ouDN)
}
catch
{
    $Context.LogMessage("$ouDN was not found", "Error") # TODO: Modify me
    return
}

# Get domain part of the email from adm-CustomAttributeText1
try
{
    $emailDomainPart = $ou.Get("adm-CustomAttributeText1")
}
catch
{

    $Context.LogMessage("The CustomAttributeText1 property of %extensionAttribute1% is empty", "Error") # TODO: Modify me
    return
}

# Set Email property
$Context.TargetObject.Put("mail", "%firstname%.%lastname%@$emailDomainPart")
$Context.TargetObject.SetInfo()

By the way, thank you for your interest in our product. :)

0

Fantastic! Script worked perfectly :)

Related questions

0 votes
1 answer

I am wanting to export a list of users including the properties of a specific custom attribute. Ideally, I would be able to run a get-admuser and filter on a custom attribute, but even an excel report with the custom attributes would work. Is this possible?

asked Sep 9, 2021 by ggallaway (300 points)
0 votes
1 answer

I have to generate an Excel sheet populated with some users informations. It works on the server itself, but not when i run it via Custom commands. There is the code that ... it does'nt open and throws an error : How to interact with com objects on Adaxes?

asked Nov 29, 2021 by diaz801 (20 points)
0 votes
1 answer

My webform is not picking info based off the property pattern template specifically the logon name and the UPN

asked Mar 8 by Keonip (160 points)
0 votes
1 answer

Not sure if this is possible but is there a mechanism to query AD to get the latest "serialised" username. We don't use proper names for usernames we use a logon ... existing contractor logon name and create the next one in sequence. A bridge too far maybe?

asked Mar 4, 2015 by bistromath (840 points)
0 votes
1 answer

Hi, I need to start Adaxes scheduled task from Powershell console running on another host. How can I do that?

asked May 21, 2020 by KIT (520 points)
2,797 questions
2,530 answers
6,594 comments
57,100 users