Set a anonymous access in virtual directory through VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rose winsle

    #1

    Set a anonymous access in virtual directory through VB.NET

    Hi guys ...

    I just wanted to create virtual directory using VB.net . i can manage that
    ... when i create the virtual directory how can i set anonymous access off.

    following is my code
    ==============

    Dim IISSchema As New System.Director yServices.Direc toryEntry("IIS://"
    & WebSite & "/Schema/AppIsolated")
    Dim CanCreate As Boolean = Not
    IISSchema.Prope rties("Syntax") .Value.ToString .ToUpper() = "BOOLEAN"
    IISSchema.Dispo se()

    If CanCreate Then
    Dim PathCreated As Boolean

    Try
    Dim IISAdmin As New
    System.Director yServices.Direc toryEntry("IIS://" & WebSite &
    "/W3SVC/1/Root")

    'make sure folder exists
    If Not System.IO.Direc tory.Exists(Pat h) Then
    System.IO.Direc tory.CreateDire ctory(Path)
    PathCreated = True
    End If

    'If the virtual directory already exists then delete it
    For Each VD As System.Director yServices.Direc toryEntry In
    IISAdmin.Childr en
    If VD.Name = AppName Then
    'IISAdmin.Invok e("Delete", New String()
    {VD.SchemaClass Name, AppName})
    'IISAdmin.Commi tChanges()
    MsgBox("Virtual directory already exists..!.",
    MsgBoxStyle.Inf ormation, "Create Virtual Directory")
    Exit Sub
    End If
    Next VD

    'Create and setup new virtual directory
    Dim VDir As System.Director yServices.Direc toryEntry =
    IISAdmin.Childr en.Add(AppName, "IIsWebVirtualD ir")
    VDir.Properties ("Path").Item(0 ) = Path
    VDir.Properties ("AppFriendlyNa me").Item(0) = AppName
    VDir.Properties ("EnableDirBrow sing").Item(0) = False
    VDir.Properties ("AccessRead"). Item(0) = True
    VDir.Properties ("AccessExecute ").Item(0) = False '
    VDir.Properties ("AccessWrite") .Item(0) = False
    VDir.Properties ("AccessScript" ).Item(0) = True
    VDir.Properties ("AuthNTLM").It em(0) = False 'Integreted
    Windows Authontocation
    VDir.Properties ("EnableDefault Doc").Item(0) = True
    VDir.Properties ("DefaultDoc"). Item(0) =
    "default.aspx,d efault.htm,defa ult.asp"
    VDir.Properties ("AspEnablePare ntPaths").Item( 0) = True

    VDir.CommitChan ges()

    VDir.Invoke("Ap pCreate", 1)


    So can you please tell me how to set Anonymous access OFF.

    -Rosy



    - R


  • vbnetdev

    #2
    Re: Set a anonymous access in virtual directory through VB.NET

    ..Properties("A uthAnonymous")( 0) = False

    --
    Get a powerful web, database, application, and email hosting with KJM
    Solutions




    "Rose winsle" <chanakya@solut ionsit.com.au> wrote in message
    news:esieYPWfGH A.4276@TK2MSFTN GP03.phx.gbl...[color=blue]
    > Hi guys ...
    >
    > I just wanted to create virtual directory using VB.net . i can manage that
    > .. when i create the virtual directory how can i set anonymous access off.
    >
    > following is my code
    > ==============
    >
    > Dim IISSchema As New System.Director yServices.Direc toryEntry("IIS://"
    > & WebSite & "/Schema/AppIsolated")
    > Dim CanCreate As Boolean = Not
    > IISSchema.Prope rties("Syntax") .Value.ToString .ToUpper() = "BOOLEAN"
    > IISSchema.Dispo se()
    >
    > If CanCreate Then
    > Dim PathCreated As Boolean
    >
    > Try
    > Dim IISAdmin As New
    > System.Director yServices.Direc toryEntry("IIS://" & WebSite &
    > "/W3SVC/1/Root")
    >
    > 'make sure folder exists
    > If Not System.IO.Direc tory.Exists(Pat h) Then
    > System.IO.Direc tory.CreateDire ctory(Path)
    > PathCreated = True
    > End If
    >
    > 'If the virtual directory already exists then delete it
    > For Each VD As System.Director yServices.Direc toryEntry In
    > IISAdmin.Childr en
    > If VD.Name = AppName Then
    > 'IISAdmin.Invok e("Delete", New String()
    > {VD.SchemaClass Name, AppName})
    > 'IISAdmin.Commi tChanges()
    > MsgBox("Virtual directory already exists..!.",
    > MsgBoxStyle.Inf ormation, "Create Virtual Directory")
    > Exit Sub
    > End If
    > Next VD
    >
    > 'Create and setup new virtual directory
    > Dim VDir As System.Director yServices.Direc toryEntry =
    > IISAdmin.Childr en.Add(AppName, "IIsWebVirtualD ir")
    > VDir.Properties ("Path").Item(0 ) = Path
    > VDir.Properties ("AppFriendlyNa me").Item(0) = AppName
    > VDir.Properties ("EnableDirBrow sing").Item(0) = False
    > VDir.Properties ("AccessRead"). Item(0) = True
    > VDir.Properties ("AccessExecute ").Item(0) = False '
    > VDir.Properties ("AccessWrite") .Item(0) = False
    > VDir.Properties ("AccessScript" ).Item(0) = True
    > VDir.Properties ("AuthNTLM").It em(0) = False 'Integreted
    > Windows Authontocation
    > VDir.Properties ("EnableDefault Doc").Item(0) = True
    > VDir.Properties ("DefaultDoc"). Item(0) =
    > "default.aspx,d efault.htm,defa ult.asp"
    > VDir.Properties ("AspEnablePare ntPaths").Item( 0) = True
    >
    > VDir.CommitChan ges()
    >
    > VDir.Invoke("Ap pCreate", 1)
    >
    >
    > So can you please tell me how to set Anonymous access OFF.
    >
    > -Rosy
    >
    >
    >
    > - R
    >[/color]


    Comment

    • Rose winsle

      #3
      Re: Set a anonymous access in virtual directory through VB.NET

      Hi vbnetdev,

      Thanks for the reply .. but i tried this. it gives me follwing error

      "Index was out of range.Must be non-negative and less than the size of
      collection, parameter name :Index"

      pls help me

      -Rose

      "vbnetdev" <vbnetdev@commu nity.nospam> wrote in message
      news:%23K0WVadf GHA.1324@TK2MSF TNGP04.phx.gbl. ..[color=blue]
      > .Properties("Au thAnonymous")(0 ) = False
      >
      > --
      > Get a powerful web, database, application, and email hosting with KJM
      > Solutions
      > http://www.kjmsolutions.com
      >
      >
      >
      > "Rose winsle" <chanakya@solut ionsit.com.au> wrote in message
      > news:esieYPWfGH A.4276@TK2MSFTN GP03.phx.gbl...[color=green]
      >> Hi guys ...
      >>
      >> I just wanted to create virtual directory using VB.net . i can manage
      >> that .. when i create the virtual directory how can i set anonymous
      >> access off.
      >>
      >> following is my code
      >> ==============
      >>
      >> Dim IISSchema As New
      >> System.Director yServices.Direc toryEntry("IIS://" & WebSite &
      >> "/Schema/AppIsolated")
      >> Dim CanCreate As Boolean = Not
      >> IISSchema.Prope rties("Syntax") .Value.ToString .ToUpper() = "BOOLEAN"
      >> IISSchema.Dispo se()
      >>
      >> If CanCreate Then
      >> Dim PathCreated As Boolean
      >>
      >> Try
      >> Dim IISAdmin As New
      >> System.Director yServices.Direc toryEntry("IIS://" & WebSite &
      >> "/W3SVC/1/Root")
      >>
      >> 'make sure folder exists
      >> If Not System.IO.Direc tory.Exists(Pat h) Then
      >> System.IO.Direc tory.CreateDire ctory(Path)
      >> PathCreated = True
      >> End If
      >>
      >> 'If the virtual directory already exists then delete it
      >> For Each VD As System.Director yServices.Direc toryEntry In
      >> IISAdmin.Childr en
      >> If VD.Name = AppName Then
      >> 'IISAdmin.Invok e("Delete", New String()
      >> {VD.SchemaClass Name, AppName})
      >> 'IISAdmin.Commi tChanges()
      >> MsgBox("Virtual directory already exists..!.",
      >> MsgBoxStyle.Inf ormation, "Create Virtual Directory")
      >> Exit Sub
      >> End If
      >> Next VD
      >>
      >> 'Create and setup new virtual directory
      >> Dim VDir As System.Director yServices.Direc toryEntry =
      >> IISAdmin.Childr en.Add(AppName, "IIsWebVirtualD ir")
      >> VDir.Properties ("Path").Item(0 ) = Path
      >> VDir.Properties ("AppFriendlyNa me").Item(0) = AppName
      >> VDir.Properties ("EnableDirBrow sing").Item(0) = False
      >> VDir.Properties ("AccessRead"). Item(0) = True
      >> VDir.Properties ("AccessExecute ").Item(0) = False '
      >> VDir.Properties ("AccessWrite") .Item(0) = False
      >> VDir.Properties ("AccessScript" ).Item(0) = True
      >> VDir.Properties ("AuthNTLM").It em(0) = False 'Integreted
      >> Windows Authontocation
      >> VDir.Properties ("EnableDefault Doc").Item(0) = True
      >> VDir.Properties ("DefaultDoc"). Item(0) =
      >> "default.aspx,d efault.htm,defa ult.asp"
      >> VDir.Properties ("AspEnablePare ntPaths").Item( 0) = True
      >>
      >> VDir.CommitChan ges()
      >>
      >> VDir.Invoke("Ap pCreate", 1)
      >>
      >>
      >> So can you please tell me how to set Anonymous access OFF.
      >>
      >> -Rosy
      >>
      >>
      >>
      >> - R
      >>[/color]
      >
      >[/color]


      Comment

      Working...