Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing settings without opening Central Admin #241

Open
Vice93 opened this issue Apr 3, 2024 · 5 comments
Open

Initializing settings without opening Central Admin #241

Vice93 opened this issue Apr 3, 2024 · 5 comments
Assignees

Comments

@Vice93
Copy link

Vice93 commented Apr 3, 2024

Hello.

When setting up EntraCP in a new farm, we are running powershell code to automate the installation process. However, we are unable to completely automate the process atm, because the global settings are not being initialized without manually navigating into the EntraCP "Global configuration" page in Central Admin.

Reproduce:

This results in [Yvand.EntraClaimsProvider.EntraCP]::GetConfiguration() returning null.

If you navigate to "Global configuration" page, the settings gets initialized and the configuration code works fine. This can maybe be fixed by GetConfiguration() also running the initialize code, or by modifying the configuration documentation to call an initialize method before calling GetConfiguration().

@Yvand
Copy link
Owner

Yvand commented Apr 3, 2024

Hi @Vice93, you can test if GetConfiguration() returns null, and if so, you can create it by running $config = [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration()

@Yvand Yvand self-assigned this Apr 3, 2024
@Vice93
Copy link
Author

Vice93 commented Apr 8, 2024

Seems this worked for most of the settings, however, it did not initialize EntraIDTenants list. Calling .Add on this throws an exception:

InvalidOperation: You cannot call a method on a null-valued expression.
At Script.ps1:34 char:4
+ $settings.EntraIDTenants.Add($tenant)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It does get initialized if I open the .aspx page though, and works in powershell afterwards.

@Yvand
Copy link
Owner

Yvand commented Apr 8, 2024

@Vice93 I would like to understand the root cause of this issue. Do you have repro steps I can use to repro this myself?

@Vice93
Copy link
Author

Vice93 commented Apr 16, 2024

On a fresh sharepoint farm, deploy EntraCP and run the following script:

Add-Type -AssemblyName "Yvand.EntraCP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=65dc6b5903b51636"

$config = [Yvand.EntraClaimsProvider.EntraCP]::GetConfiguration()
if ($null -eq $config)
{
    $config = [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration()
    if ($null -eq $config.Settings.EntraIDTentants)
    {
    	Write-Error "Could not create configuration for EntraCP"
        return
    }
}

Just make sure you do not do anything manual like navigating to central admin EntraCP configuration page before running the script (the point is trying to automate the entire process).

@Yvand
Copy link
Owner

Yvand commented Apr 16, 2024

@Vice93 I basically do the same, and $config.Settings.EntraIDTentants should indeed not be null.
When running [Yvand.EntraClaimsProvider.EntraCP]::CreateConfiguration() you should see this message in the log:

04/16/2024 09:50:06.78	powershell.exe (0x1660)	0x0864	EntraCP	Core	1337	High	Created configuration 'EntraCPConfig' with Id 1db24d85-b10e-4d06-b378-8cfd05a129f3	5d832b90-b879-0003-e638-0e32ce8fda01

Is it recorded in your environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants