Skip to content

Commit d9aec8e

Browse files
committed
Merge pull request #902 from dmorgan3405/add_ability_to_change_identity
Added Ability to specify Identity for AppPool
2 parents 1075270 + 345f79c commit d9aec8e

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

src/app/Fake.IIS/IISHelper.fs

+22-13
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,6 @@ let Site (name : string) protocol binding (physicalPath : string) appPool (mgr :
5151
site.ApplicationDefaults.ApplicationPoolName <- appPool
5252
site
5353

54-
let ApplicationPool (name : string) (allow32on64:bool) (runtime:string) (mgr : ServerManager) =
55-
let appPool = mgr.ApplicationPools.[name]
56-
match (appPool) with
57-
| null ->
58-
let pool = mgr.ApplicationPools.Add(name)
59-
pool.Enable32BitAppOnWin64 <- allow32on64
60-
pool.ManagedRuntimeVersion <- runtime
61-
pool
62-
| _ ->
63-
appPool.Enable32BitAppOnWin64 <- allow32on64
64-
appPool.ManagedRuntimeVersion <- runtime
65-
appPool
66-
6754
let Application (virtualPath : string) (physicalPath : string) (site : Site) (mgr : ServerManager) =
6855
let app = site.Applications.[virtualPath]
6956
match (app) with
@@ -72,6 +59,28 @@ let Application (virtualPath : string) (physicalPath : string) (site : Site) (mg
7259

7360
let commit (mgr : ServerManager) = mgr.CommitChanges()
7461

62+
type ApplicationPoolConfig(name : string, ?runtime:string, ?allow32on64:bool, ?identity : ProcessModelIdentityType) = class
63+
member this.name = name
64+
member this.runtime = defaultArg runtime "v4.0"
65+
member this.allow32on64 = defaultArg allow32on64 false
66+
member this.identity = defaultArg identity ProcessModelIdentityType.ApplicationPoolIdentity
67+
end
68+
69+
let private MergeAppPoolProperties (appPool:ApplicationPool)(config:ApplicationPoolConfig) =
70+
appPool.Enable32BitAppOnWin64 <- config.allow32on64
71+
appPool.ManagedRuntimeVersion <- config.runtime
72+
appPool.ProcessModel.IdentityType <- config.identity
73+
appPool
74+
75+
let ApplicationPool (config: ApplicationPoolConfig) (mgr : ServerManager) =
76+
let appPool = mgr.ApplicationPools.[config.name]
77+
match (appPool) with
78+
| null ->
79+
let pool = mgr.ApplicationPools.Add(config.name)
80+
MergeAppPoolProperties pool config
81+
| _ ->
82+
MergeAppPoolProperties appPool config
83+
7584
let IIS (site : ServerManager -> Site)
7685
(appPool : ServerManager -> ApplicationPool)
7786
(app : (Site -> ServerManager -> Application) option) =

src/app/Fake.IIS/Script.fsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#r @"..\..\..\packages\Microsoft.Web.Administration.7.0.0.0\lib\net20\Microsoft.Web.Administration.dll"
1+
#r @"..\..\..\packages\Microsoft.Web.Administration\lib\net20\Microsoft.Web.Administration.dll"
22
#r @"..\..\..\build\FakeLib.dll"
33

44
#load "IISHelper.fs"
55
open Fake.IISHelper
6+
open Microsoft.Web
67

78
let siteName = "fake.site"
89
let appPool = "fake.appPool"
@@ -12,15 +13,18 @@ let appDir = @"C:\Users"
1213

1314
UnlockSection "system.webServer/security/authentication/anonymousauthentication"
1415

16+
let dotNetFourAppPool = ApplicationPoolConfig(siteName, allow32on64 = true, identity = Administration.ProcessModelIdentityType.LocalSystem)
17+
let dotNetTwoAppPool = ApplicationPoolConfig(siteName, runtime = "v2.0", allow32on64 = true)
18+
1519
(IIS
1620
(Site siteName "http" port @"C:\inetpub\wwwroot" appPool)
17-
(ApplicationPool appPool true "v4.0")
21+
(ApplicationPool dotNetFourAppPool)
1822
(Some(Application vdir appDir)))
1923

2024
(IIS
2125
(Site siteName "http" port @"C:\inetpub\wwwroot" appPool)
22-
(ApplicationPool appPool true "v2.0")
26+
(ApplicationPool dotNetTwoAppPool)
2327
(Some(Application "/vdir2" @"C:\temp")))
2428

2529
deleteSite siteName
26-
deleteApplicationPool appPool
30+
deleteApplicationPool appPool

0 commit comments

Comments
 (0)