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

Added Ability to specify Identity for AppPool #902

Merged
merged 1 commit into from
Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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