Skip to content

Commit

Permalink
Merge pull request #902 from dmorgan3405/add_ability_to_change_identity
Browse files Browse the repository at this point in the history
Added Ability to specify Identity for AppPool
  • Loading branch information
forki committed Aug 10, 2015
2 parents 1075270 + 345f79c commit d9aec8e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
35 changes: 22 additions & 13 deletions src/app/Fake.IIS/IISHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ let Site (name : string) protocol binding (physicalPath : string) appPool (mgr :
site.ApplicationDefaults.ApplicationPoolName <- appPool
site

let ApplicationPool (name : string) (allow32on64:bool) (runtime:string) (mgr : ServerManager) =
let appPool = mgr.ApplicationPools.[name]
match (appPool) with
| null ->
let pool = mgr.ApplicationPools.Add(name)
pool.Enable32BitAppOnWin64 <- allow32on64
pool.ManagedRuntimeVersion <- runtime
pool
| _ ->
appPool.Enable32BitAppOnWin64 <- allow32on64
appPool.ManagedRuntimeVersion <- runtime
appPool

let Application (virtualPath : string) (physicalPath : string) (site : Site) (mgr : ServerManager) =
let app = site.Applications.[virtualPath]
match (app) with
Expand All @@ -72,6 +59,28 @@ let Application (virtualPath : string) (physicalPath : string) (site : Site) (mg

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

type ApplicationPoolConfig(name : string, ?runtime:string, ?allow32on64:bool, ?identity : ProcessModelIdentityType) = class
member this.name = name
member this.runtime = defaultArg runtime "v4.0"
member this.allow32on64 = defaultArg allow32on64 false
member this.identity = defaultArg identity ProcessModelIdentityType.ApplicationPoolIdentity
end

let private MergeAppPoolProperties (appPool:ApplicationPool)(config:ApplicationPoolConfig) =
appPool.Enable32BitAppOnWin64 <- config.allow32on64
appPool.ManagedRuntimeVersion <- config.runtime
appPool.ProcessModel.IdentityType <- config.identity
appPool

let ApplicationPool (config: ApplicationPoolConfig) (mgr : ServerManager) =
let appPool = mgr.ApplicationPools.[config.name]
match (appPool) with
| null ->
let pool = mgr.ApplicationPools.Add(config.name)
MergeAppPoolProperties pool config
| _ ->
MergeAppPoolProperties appPool config

let IIS (site : ServerManager -> Site)
(appPool : ServerManager -> ApplicationPool)
(app : (Site -> ServerManager -> Application) option) =
Expand Down
12 changes: 8 additions & 4 deletions src/app/Fake.IIS/Script.fsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#r @"..\..\..\packages\Microsoft.Web.Administration.7.0.0.0\lib\net20\Microsoft.Web.Administration.dll"
#r @"..\..\..\packages\Microsoft.Web.Administration\lib\net20\Microsoft.Web.Administration.dll"
#r @"..\..\..\build\FakeLib.dll"

#load "IISHelper.fs"
open Fake.IISHelper
open Microsoft.Web

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

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

let dotNetFourAppPool = ApplicationPoolConfig(siteName, allow32on64 = true, identity = Administration.ProcessModelIdentityType.LocalSystem)
let dotNetTwoAppPool = ApplicationPoolConfig(siteName, runtime = "v2.0", allow32on64 = true)

(IIS
(Site siteName "http" port @"C:\inetpub\wwwroot" appPool)
(ApplicationPool appPool true "v4.0")
(ApplicationPool dotNetFourAppPool)
(Some(Application vdir appDir)))

(IIS
(Site siteName "http" port @"C:\inetpub\wwwroot" appPool)
(ApplicationPool appPool true "v2.0")
(ApplicationPool dotNetTwoAppPool)
(Some(Application "/vdir2" @"C:\temp")))

deleteSite siteName
deleteApplicationPool appPool
deleteApplicationPool appPool

0 comments on commit d9aec8e

Please sign in to comment.