No Gravatar

I know this is VB.NET but i was in a hurry and my C# sucks
this is mostly cobbled togther from other stuff I found on the net, none of which did EXACTLY what I needed
When I get the time i will publish some of my other functions, including IIS6 site create and IIS6 FTP Profile Create

This is a simple VB.NET function to create and IIS6 Application pool
This function is designed to specify the UserId and Password for the AppPool Identity and was used in an environment where domain credentials were used

Function CreateAppPool(ByVal StrMachine As String, ByVal AppName As String, ByVal UserName As String, ByVal Password As String) As  String

CreateAppPool = “success”
Dim foundapp As Boolean
Dim apppools As DirectoryEntries
Dim apppool2 As DirectoryEntry
Dim apppool As DirectoryEntry
Dim NewAppPool As Object
foundapp = False
apppool2 = New DirectoryEntry(“IIS://” & StrMachine & “/w3svc/AppPools”)
apppools = apppool2.Children
‘test for duplicate poolname
For Each apppool In apppools ‘ scan each current app pool for check its name
  If UCase(apppool.Name) = UCase(AppName) Then ‘ no need to check class type as everything at this level is a AppPool
    foundapp = True
  End If
Next
If Not foundapp Then
  ‘create the APP Pool and set unique information, most of the data is inherited
  NewAppPool = apppool2.Children.Add(AppName, “IIsApplicationPool”)
  NewAppPool.Properties(
“AppPoolIdentityType”).Item(0) = 3
  NewAppPool.Properties(
“WAMUserName”).Item(0) = UserName
  NewAppPool.Properties(
“WAMUserPass”).Item(0) = Password
  NewAppPool.CommitChanges()
  NewAppPool =
Nothing
Else
  CreateAppPool = “Duplicate AppPool found”
End If
  apppool2 = Nothing
  apppools = Nothing
End Function

Bookmark and Share