-
Notifications
You must be signed in to change notification settings - Fork 5
/
Install.ps1
53 lines (39 loc) · 1.52 KB
/
Install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#Requires -RunAsAdministrator
# Install the provider
Set-Location -Path "C:\Program Files\PrivacyIDEA AD FS"
$myPath = Get-Location
$myDll = 'privacyIDEA-ADFSProvider.dll'
$myDllFullName = (get-item $myDll).FullName
function Gac-Util
{
param (
[parameter(Mandatory = $true)][string] $assembly
)
try
{
$Error.Clear()
[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null
[System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish
if (!(Test-Path $assembly -type Leaf) )
{ throw "The assembly $assembly does not exist" }
if ([System.Reflection.Assembly]::LoadFile($assembly).GetName().GetPublicKey().Length -eq 0 )
{ throw "The assembly $assembly must be strongly signed" }
$publish.GacInstall($assembly)
Write-Host "`t`t$($MyInvocation.InvocationName): Assembly $assembly gacced"
}
catch
{
Write-Host "`t`t$($MyInvocation.InvocationName): $_"
}
}
# check event source
if (!([System.Diagnostics.EventLog]::SourceExists("privacyIDEAProvider")))
{
New-EventLog -LogName "AD FS/Admin" -Source "privacyIDEAProvider"
Write-Host "Log source created"
}
Gac-Util $myDllFullName
$appFullName = ([system.reflection.assembly]::loadfile($myDllFullName)).FullName
$typeName = "privacyIDEAADFSProvider.Adapter, "+$appFullName
Register-AdfsAuthenticationProvider -TypeName $typeName -Name "privacyIDEAADFSProvider"
Restart-Service adfssrv