I need to connect to Exchange Online using specific service principal, but I am getting error image.png

I am trying to authenticate via Connect-ExchangeOnline -AccessToken $token -Organization $organization

We have latest Adaxes version installed btw aka 3.8.0 version of the ExchangeOnlineManagement module is used automatically.

by (1.0k points)

1 Answer

by (307k points)
0 votes

Hello,

Unfortunately, there is no such possibility. Using method $Context.CloudServices.ConnectExchangeOnline() is the only option in Adaxes scripts. However, thank you for the suggestion. We forwarded it to the corresponding department for consideration.

by (1.0k points)
0

So it means I have to grant required permissions to service account running Adaxes service?

by (307k points)
+1

Hello,

The Adaxes service account (specified during Adaxes installation) does not take any part in establishing the connection to Exchange Online. The credentials of the user or application account specified for your Microsoft 365 tenant. For details on how to check/change the credentials, see https://www.adaxes.com/help/ChangeTenantServiceAccount. No matter which of the two is used, they were granted most of the usually required permissions for the Microsoft 365 tenant registration in Adaxes.

by (1.0k points)
0

OK, I have added permission Exchange.ManageAsAppV2 and one of the EXO Roles to the tenant service principal, but when invoking $Context.CloudServices.ConnectExchangeOnline() inside the adaxes report code I get error image.png

Is there anything else what needs to be done to have this working?

Thanks

by (307k points)
0

Hello,

Are you executing your script in a report? If so, the method must have a parameter. For details, see https://adaxes.com/sdk/ReportCloudServicesScriptContextClass/#ConnectExchangeOnline_details.

by (1.0k points)
0

I see.

OK I have customized the code to look like this image.png

and now I am getting following error image.png

$targetDN should be DN of the user specified in the parameter picker, so not sure what is wrong now

by (307k points)
0

Hello,

Do you have your Microsoft 365 tenant registered in Adaxe with the credentials of a user account? If that is correct, the error is expected and is on the Microsoft side. To resolve the issue, change the tenant registration in Adaxes to a Microsoft Entra app. The following article will be helpful: https://www.adaxes.com/help/RegisterAdaxesAsAppMicrosoftAzure.

by (1.0k points)
0

We are already using an app (service principal I've already mentioned)

by (307k points)
0

Hello,

For further troubleshooting, please, execute the below command in Windows PowerShell on the computer where Adaxes service runs and provide us with a screenshot of the output.

Get-InstalledModule "ExchangeOnlineManagement" -AllVersions 

Also, please, provide us with a screenshot of the Multi-server environment dialog. The dialog displays how many Adaxes services you have and what their versions are. For information on how to view it, see https://www.adaxes.com/help/MultiServerEnvironment.

You can post the screenshots here or send them to us at support@adaxes.com.

by (1.0k points)
0

image.png

image.png

by (307k points)
0

Hello,

Did you execute the command in PowerShell 7? If so, please, execute it in Windows PowerShell now.

by (1.0k points)
0

Yes I did, but same output is returned in windows powershell image.png

by (307k points)
0

Hello,

Also, try the below command in both Windows PowerShell and PowerShell 7. Does it give the same results?

Get-Module ExchangeOnlineManagement -listavailable
by (1.0k points)
0

There was 3.6.0 version. I have deleted it and restarted Adaxes services.

Now no ExchangeOnlineManagement is detected in desktop nor core powershell, but I am getting still the same error.image.png

by (307k points)
0

Hello,

It looks like Adaxes is unable to install the module automatically. You can do it manually using the below command.

Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.8.0 

After the installation, restart the Softerra Adaxes Service Windows service.

by (1.0k points)
0

I have tried to explicitly import installed 3.8.0 version but no difference.

Anyway I can see that the Adaxes builtin EXO module is being imported image.png

So I don't think this is the problem here.

(the output is retrieved via command get-module | foreach {Write-Warning "$($_.Name) $($_.Version) $($_.Path)"} and is made before the exo auth occurs)

by (307k points)
0

Hello,

Do we understand correctly that you face the error after clicking Generate for the report with the script?

Are you able to view properties of Exchange Online recipients in Adaxes via the UI? For example, by just opening properties of a user in the Administration console and activating the Exchange tab.

Related questions

I'd like to run code against the Adaxes service but need to pass my Admin credentials. How do I send different creds than the current user?

asked Jul 27, 2020 by ComputerHabit (810 points)
0 votes
1 answer

The script create two reports of inactive workstation operating systems. The report is too detailed to run from one of the adaxes reports. Basically how can I set the script up to ... sure How I did this but I can't find it now (probably something simple).

asked Nov 30, 2022 by mightycabal (1.2k points)
0 votes
1 answer

How do I setup Adaxes for Exchange Online Hybrid mode? When I look at one of the users that has been migrated to Exchange Online I get the message of The operation couldn't be performed because object couldn't be found on domain controller.

asked Dec 5, 2019 by Lucas.Miller (20 points)
0 votes
1 answer

Hi, In the SDK I find information on how to use Powershell to read and create scripts in custom commands and business rules, but I can not find the same for ... information like the embedded scripts for the report and custom columns? -- Morten A. Steien

asked Jul 27, 2023 by Morten A. Steien (300 points)
0 votes
1 answer

The checkbox is not selected (False) by default.

asked May 30, 2022 by john.harding (70 points)
0 votes
1 answer