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

OfficeOnlineServerFarm: Added hierarchy and LDAP:// support for FarmOU #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- OfficeOnlineServerFarm
- Added hierarchy and LDAP:// support for FarmOU

### Changed

- OfficeOnlineServerDsc
Expand Down
4 changes: 4 additions & 0 deletions src/DSCResources/MSFT_OfficeOnlineServerFarm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ have already been installed, but when this is run it will establish a new farm.
means that this resource only needs to be used on the first server in a deployment,
all other servers should use the OfficeOnlineServerMachine resource to join
the farm.

FarmOU can be specified using path or LDAP syntax. For example "Servers/OOS" or
"LDAP://OU=OOS,OU=Servers". ntds:// format is supported by the underlying
Office Online Server Management Shell but is not implemented in OfficeOnlineServerDSC.
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@
param ()

return Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | `
Select-Object DisplayName, DisplayVersion | `
Where-Object {
$_.DisplayName -eq "Microsoft Office Web Apps Server 2013" -or `
$_.DisplayName -eq "Microsoft Office Online Server"
} | ForEach-Object -Process {
return [Version]::Parse($_.DisplayVersion)
} | Select-Object -First 1
Select-Object DisplayName, DisplayVersion | `
Where-Object {
$_.DisplayName -eq "Microsoft Office Web Apps Server 2013" -or `

Check warning on line 214 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L212-L214

Added lines #L212 - L214 were not covered by tests
$_.DisplayName -eq "Microsoft Office Online Server"
} | ForEach-Object -Process {
return [Version]::Parse($_.DisplayVersion)
} | Select-Object -First 1

Check warning on line 218 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L216-L218

Added lines #L216 - L218 were not covered by tests
}


Expand Down Expand Up @@ -332,12 +332,30 @@
$ExistingOU
)

if ($DesiredOU -like "LDAP://*")

Check warning on line 335 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L335

Added line #L335 was not covered by tests
{
$sanitizedFarmOU = $DesiredOU -replace 'LDAP://'

Check warning on line 337 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L337

Added line #L337 was not covered by tests
}
elseif ($DesiredOU -like "ntds://*")

Check warning on line 339 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L339

Added line #L339 was not covered by tests
{
throw "FarmOU in ntds:// format is not supported";

Check warning on line 341 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L341

Added line #L341 was not covered by tests
}
else
{
$str = ($DesiredOU -replace '/', '\').Trim('\');
$splitOu = $str -split '\\'
[array]::Reverse($splitOu)
$sanitizedFarmOU = "OU=" + ($splitOu -join ",OU=");

Check warning on line 348 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L345-L348

Added lines #L345 - L348 were not covered by tests
}

$adsi = [adsisearcher]'(objectCategory=organizationalUnit)'
$adsi.Filter = "name=$DesiredOU"
$ou = $adsi.FindAll()
$searchRoot = "," + $adsi.SearchRoot.Path -replace 'LDAP://'

Check warning on line 352 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L352

Added line #L352 was not covered by tests

$adsi.Filter = "distinguishedName=$($sanitizedFarmOU)$searchRoot"
$ou = $adsi.FindOne()

Check warning on line 355 in src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1

View check run for this annotation

Codecov / codecov/patch

src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1#L354-L355

Added lines #L354 - L355 were not covered by tests

if ($ou.path)
{
$searchRoot = "," + $adsi.SearchRoot.Path -replace 'LDAP://'
$ldapResult = $ou.path -replace $searchRoot
Write-Verbose -Message "LDAP search result: $ldapResult"
Write-Verbose "Current Farm OU: $ExistingOU"
Expand Down