473,410 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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.DirectoryServices.DirectoryEntry("IIS://"
& WebSite & "/Schema/AppIsolated")
Dim CanCreate As Boolean = Not
IISSchema.Properties("Syntax").Value.ToString.ToUp per() = "BOOLEAN"
IISSchema.Dispose()

If CanCreate Then
Dim PathCreated As Boolean

Try
Dim IISAdmin As New
System.DirectoryServices.DirectoryEntry("IIS://" & WebSite &
"/W3SVC/1/Root")

'make sure folder exists
If Not System.IO.Directory.Exists(Path) Then
System.IO.Directory.CreateDirectory(Path)
PathCreated = True
End If

'If the virtual directory already exists then delete it
For Each VD As System.DirectoryServices.DirectoryEntry In
IISAdmin.Children
If VD.Name = AppName Then
'IISAdmin.Invoke("Delete", New String()
{VD.SchemaClassName, AppName})
'IISAdmin.CommitChanges()
MsgBox("Virtual directory already exists..!.",
MsgBoxStyle.Information, "Create Virtual Directory")
Exit Sub
End If
Next VD

'Create and setup new virtual directory
Dim VDir As System.DirectoryServices.DirectoryEntry =
IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
VDir.Properties("Path").Item(0) = Path
VDir.Properties("AppFriendlyName").Item(0) = AppName
VDir.Properties("EnableDirBrowsing").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").Item(0) = False 'Integreted
Windows Authontocation
VDir.Properties("EnableDefaultDoc").Item(0) = True
VDir.Properties("DefaultDoc").Item(0) =
"default.aspx,default.htm,default.asp"
VDir.Properties("AspEnableParentPaths").Item(0) = True

VDir.CommitChanges()

VDir.Invoke("AppCreate", 1)
So can you please tell me how to set Anonymous access OFF.

-Rosy

- R
May 22 '06 #1
2 3884
..Properties("AuthAnonymous")(0) = False

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Rose winsle" <ch******@solutionsit.com.au> wrote in message
news:es**************@TK2MSFTNGP03.phx.gbl...
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.DirectoryServices.DirectoryEntry("IIS://"
& WebSite & "/Schema/AppIsolated")
Dim CanCreate As Boolean = Not
IISSchema.Properties("Syntax").Value.ToString.ToUp per() = "BOOLEAN"
IISSchema.Dispose()

If CanCreate Then
Dim PathCreated As Boolean

Try
Dim IISAdmin As New
System.DirectoryServices.DirectoryEntry("IIS://" & WebSite &
"/W3SVC/1/Root")

'make sure folder exists
If Not System.IO.Directory.Exists(Path) Then
System.IO.Directory.CreateDirectory(Path)
PathCreated = True
End If

'If the virtual directory already exists then delete it
For Each VD As System.DirectoryServices.DirectoryEntry In
IISAdmin.Children
If VD.Name = AppName Then
'IISAdmin.Invoke("Delete", New String()
{VD.SchemaClassName, AppName})
'IISAdmin.CommitChanges()
MsgBox("Virtual directory already exists..!.",
MsgBoxStyle.Information, "Create Virtual Directory")
Exit Sub
End If
Next VD

'Create and setup new virtual directory
Dim VDir As System.DirectoryServices.DirectoryEntry =
IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
VDir.Properties("Path").Item(0) = Path
VDir.Properties("AppFriendlyName").Item(0) = AppName
VDir.Properties("EnableDirBrowsing").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").Item(0) = False 'Integreted
Windows Authontocation
VDir.Properties("EnableDefaultDoc").Item(0) = True
VDir.Properties("DefaultDoc").Item(0) =
"default.aspx,default.htm,default.asp"
VDir.Properties("AspEnableParentPaths").Item(0) = True

VDir.CommitChanges()

VDir.Invoke("AppCreate", 1)
So can you please tell me how to set Anonymous access OFF.

-Rosy

- R

May 22 '06 #2
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" <vb******@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
.Properties("AuthAnonymous")(0) = False

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Rose winsle" <ch******@solutionsit.com.au> wrote in message
news:es**************@TK2MSFTNGP03.phx.gbl...
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.DirectoryServices.DirectoryEntry("IIS://" & WebSite &
"/Schema/AppIsolated")
Dim CanCreate As Boolean = Not
IISSchema.Properties("Syntax").Value.ToString.ToUp per() = "BOOLEAN"
IISSchema.Dispose()

If CanCreate Then
Dim PathCreated As Boolean

Try
Dim IISAdmin As New
System.DirectoryServices.DirectoryEntry("IIS://" & WebSite &
"/W3SVC/1/Root")

'make sure folder exists
If Not System.IO.Directory.Exists(Path) Then
System.IO.Directory.CreateDirectory(Path)
PathCreated = True
End If

'If the virtual directory already exists then delete it
For Each VD As System.DirectoryServices.DirectoryEntry In
IISAdmin.Children
If VD.Name = AppName Then
'IISAdmin.Invoke("Delete", New String()
{VD.SchemaClassName, AppName})
'IISAdmin.CommitChanges()
MsgBox("Virtual directory already exists..!.",
MsgBoxStyle.Information, "Create Virtual Directory")
Exit Sub
End If
Next VD

'Create and setup new virtual directory
Dim VDir As System.DirectoryServices.DirectoryEntry =
IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
VDir.Properties("Path").Item(0) = Path
VDir.Properties("AppFriendlyName").Item(0) = AppName
VDir.Properties("EnableDirBrowsing").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").Item(0) = False 'Integreted
Windows Authontocation
VDir.Properties("EnableDefaultDoc").Item(0) = True
VDir.Properties("DefaultDoc").Item(0) =
"default.aspx,default.htm,default.asp"
VDir.Properties("AspEnableParentPaths").Item(0) = True

VDir.CommitChanges()

VDir.Invoke("AppCreate", 1)
So can you please tell me how to set Anonymous access OFF.

-Rosy

- R


May 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: muzerb | last post by:
What are the account requirements for aspx pages to be accesse anonymously on Windows 2003 server?. When I view my aspx page in a browser locally or remotely I always ge prompted for user and...
1
by: yurps | last post by:
Hello, I got a weird problem...I didn't set up this machine so I don't know what possibly went wrong...IIS set up after VS.NET.. On a virtual directory for a web app...I go to properties and...
3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
2
by: Kevin Hoskins | last post by:
Is there anyway to force authentication of the Anonymous user? Here is the situation: I have an ASP.NET page which calls an assembly which requires a certain level of permissions. The page is...
4
by: Martin | last post by:
Hi, I am getting an "Access Denied" error when attempting to browse asp.net pages. I have installed ASP.NET 1.1.4322 on a domain controller. The machine also has ASP.NET 1.0.3705 installed on...
0
by: Yogesh Pancholi | last post by:
For some unexplained reason, I am suddenly unable to browse to a virtual directory on my laptop. I have a number of sample websites to which I could happliy browse up until last week. As of Monday,...
5
by: jhcorey | last post by:
We're using a third-party treeview and found that the functionality we need works only when we set the web site security to allow Anonymous Access. We also need the user's network id, which we...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
1
by: AAOMTim | last post by:
I have a web project in which I would like to structure my top level directory to provide a user with anonymous access and a subdirectory for secure access that uses forms-based authentication. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.