0 votes

In our environment, we have dirsync setup to assign the Office365 username based on the email property of the on-prem user.

In Adaxes, if a newly created user doesn't have an Office 365 account when assigned licenses or usage location, it appears to be pre-provisioning that account. The problem is that it is using the UPN of that user. Is it possible to modify this setting to instead utilize a property of our choosing?

Currently using product version: 3.10.15918.0

by (120 points)
0

Hello,

There is no possibility to change the template used to generate username in Office 365 during provisioning of a user. However, you can use a script to change the username in Office 365 after the provisioning. If the solution meets your needs, we will provide you with the script.

0

Yes, I believe that can work in our system. I would appreciate having that script.

1 Answer

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

Hello,

Here is the script. You can use the script in Business Rules, Custom Commands and Scheduled Tasks. In the script, $newID specifies a template for a new Office 365 ID. You can use value references in the template (e.g. %firstname%). When the script runs, the value references will be replaced with property values of the user on which the rule, command or task is executed. For details, see https://www.adaxes.com/help/?ValueRefer ... ormat.html.

$newID = "%firstname:lower%.%lastname:lower%@example.com" # TODO: modify me

# Get the Office 365 object ID
try
{
    $objectId = [GUID]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    $Context.LogMessage("The user doesn't have an Office 365 account", "Warning")
    return
}

# Connect to Office 365
$Credential = $Context.GetOffice365Credential()
Connect-MsolService -Credential $Credential

# Check whether the Office 365 User ID differs from the new ID
$userO365 = Get-MsolUser -ObjectId $objectId
$o365Username = $userO365.UserPrincipalName

if ($o365Username -ieq $newID)
{
    return # No changes needed
}

# Change the Office 365 User ID
Set-MsolUserPrincipalName -ObjectId $objectId -NewUserPrincipalName $newID
$Context.LogMessage("Office 365 User ID has been changed to: $newID", "Information")

For the script to work, you need to install Microsoft Azure Active Directory Module for Windows PowerShell on each computer where Adaxes service is running.

If you have a Business Rule which assigns Office 365 licenses to users, you can add the Run a program or PowerShell script action right after the Activate or modify Office 365 account action to update the ID automatically each time a user account is provisioned via Adaxes. The result should be like the following:

If you want to update Office 365 ID manually, you can use the script in a Custom Command configured for User object type and execute it on the users which you want to update. For information on how to create Custom Commands, have a look at the following tutorial: https://www.adaxes.com/tutorials_Active ... ommand.htm.

Also, you can use the script in a Scheduled Task to update Office 365 IDs on a periodic basis. The task should be configured for User object type. For information on how to create Scheduled Tasks, have a look at the following tutorial: https://www.adaxes.com/tutorials_Automa ... gement.htm.

0

This has worked perfectly. Thanks!

Related questions

0 votes
1 answer

Pretty simple question. Upon user provisioning, based on business unit, is there a way to have the new O365 mailbox and user be added to an existing distribution group in ... could do this with local AD distribution groups, but that is currently not the case.

asked Sep 10, 2015 by eponerine (50 points)
0 votes
1 answer

I am trying to automate some of my o365 scripts so that the helpdesk can run them with elevated permissions and not have that ... -Credential $o365Credentials -Authentication Basic -AllowRedirection Import-PSSession $session -AllowClobber -DisableNameChecking

asked Nov 23, 2018 by jbadry (410 points)
0 votes
1 answer

Hi, We encounter an error on one of our Adaxes service (Adaxes 2016 3.7.13430) when activating Licence for new user : Softerra.Adaxes.CommandPipeline.CommandProcessingException: The ... stack trace --- Any idea ? Thank you in advance for your help regards

asked Sep 20, 2017 by smasset (730 points)
0 votes
1 answer

I am getting the following error within Adaxes when I try to connect to my Office 365 tenant or run any powershell scripts against it. Failed to create an Office ... .Runspaces.InitialSessionState' threw an exception. Does anybody have a solution for this :?:

asked Jun 17, 2015 by rmedeiros (360 points)
0 votes
1 answer

I have a business rule to create a user in our AD, and then have it create a new O365 account and assign it a license. How can I have it create a temporary password that I specify during that business rule?

asked Jun 17, 2020 by keecit (40 points)
2,740 questions
2,474 answers
6,475 comments
1,373,462 users