473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
May 22 '06 #1
2 3896
..Properties("A uthAnonymous")( 0) = False

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

"Rose winsle" <ch******@solut ionsit.com.au> wrote in message
news:es******** ******@TK2MSFTN GP03.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.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

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******@commu nity.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
.Properties("Au thAnonymous")(0 ) = False

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

"Rose winsle" <ch******@solut ionsit.com.au> wrote in message
news:es******** ******@TK2MSFTN GP03.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.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


May 23 '06 #3

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

Similar topics

3
5193
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 password. When I provide credentials for user i the admin group the page displays correctly. I do not get prompted when viewing .htm files. I...
1
1608
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 click on the 'Directory Security' tab, click the 'Edit' button,check anonymous access, type in username/password for account, check 'Integrated...
3
2454
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 wrong? I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains: //**************************** //****************************...
2
2897
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 running in a virtual server whose anonymous user is a network account with the required permissions. This allows anyone to view the page and see the...
4
2245
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 it. The machine is win 2k server. IIS is installed. I have already run aspnet_regiis - i to reinstall the .net framework.
0
1763
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, if I browse to any of the sites, I get an HttpException saying "The directory does not exist or is not accessible because of security settings." I...
5
6628
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 could get from System.Web.HttpContext.User.Identity.Name if we don't allow AA. Is the user's id somehow still accessible in the app even though...
3
7945
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 C:\Inetpub\wwwroot\RunReportASP is the directory of my virtual directory for my app. In it's properties I did check "Write" as a permission. What else...
1
1240
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. I'm under the impression that I need 2 web.config files: one in my top level directory for anonymous access and one in my underlying secure directory...
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6036
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.