473,661 Members | 2,431 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UnauthorizedAcc essException when creating virtual dir from asp.net

In c# we have a function that creates a virtual directory in IIS 6.0
using DirectoryServic es API. The code looks like this:

// log in to IIS
DirectoryEntry rootDir = new
DirectoryEntry( "IIS://localhost/W3SVC/1/Root",ADMIN_USR ,ADMIN_PSWD,Aut henticationType s.Secure);
// create a child virtual directory
DirectoryEntry virtualDir = rootDir.Childre n.Add(name,
rootDir.SchemaC lassName);
// set the virtual directory's physical path
virtualDir.Prop erties["Path"][0] = path;

// the following line throws an UnauthorizedAcc essException if called
from a .aspx page
// but not from a windows desktop application
virtualDir.Comm itChanges();

Logged in as Administrator when I run this code within a windows
application there is no problem. When I run this code called by a
ASP.NET web application I get a "System.Unautho rizedAccessExce ption:
Access is denied." exception.

The web site where the .aspx page that calls this code is set up with
Integrated Windows Authentication or Basic Authentication and a
user/password dialog appears the administrator account is used. In the
web.config for the site these are the settings:

<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Within the above mentioned code there are entries in a log that show
the process identity of:

WindowsIdentity .GetCurrent().N ame;
Thread.CurrentP rincipal.Identi ty.Name;

and both give the same result: DOMAIN\Administ rator. Is spite of this
we still get the UnauthorizedAcc essException.

What settings have to be changed to get this to work. Any ideas?

Thanks in advance.
Nov 18 '05 #1
1 1840
i think its considering your default ASPNet user identity. just to test, try
giving the required permissions to your default ASPNet user account
only for test purposes, you can change machine.config->processModel->
userName to SYSTEM account and test it.

but remove this after the test. i think you need to give the required
permissions to aspnet user (put him under power users group).
Av.

"Hal 9000" <ha*******@yaho o.com> wrote in message
news:40******** *************** ***@posting.goo gle.com...
In c# we have a function that creates a virtual directory in IIS 6.0
using DirectoryServic es API. The code looks like this:

// log in to IIS
DirectoryEntry rootDir = new
DirectoryEntry( "IIS://localhost/W3SVC/1/Root",ADMIN_USR ,ADMIN_PSWD,Aut henticationType s.Secure);
// create a child virtual directory
DirectoryEntry virtualDir = rootDir.Childre n.Add(name,
rootDir.SchemaC lassName);
// set the virtual directory's physical path
virtualDir.Prop erties["Path"][0] = path;

// the following line throws an UnauthorizedAcc essException if called
from a .aspx page
// but not from a windows desktop application
virtualDir.Comm itChanges();

Logged in as Administrator when I run this code within a windows
application there is no problem. When I run this code called by a
ASP.NET web application I get a "System.Unautho rizedAccessExce ption:
Access is denied." exception.

The web site where the .aspx page that calls this code is set up with
Integrated Windows Authentication or Basic Authentication and a
user/password dialog appears the administrator account is used. In the
web.config for the site these are the settings:

<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Within the above mentioned code there are entries in a log that show
the process identity of:

WindowsIdentity .GetCurrent().N ame;
Thread.CurrentP rincipal.Identi ty.Name;

and both give the same result: DOMAIN\Administ rator. Is spite of this
we still get the UnauthorizedAcc essException.

What settings have to be changed to get this to work. Any ideas?

Thanks in advance.

Nov 18 '05 #2

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

Similar topics

2
4117
by: GM | last post by:
Any help is greatly appreciated! I'm up against a meeting deadline. Directory.CreateDirectory Method throws UnauthorizedAccessException Here is the path: "C:\JumpStart\JumpStart\sites\Proto\images\sites.e-Plaza.org\Alece" Everything before 'Alece' already exists.
12
7989
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files File.Delete(Filename) Next Catch ex As Exception
5
8949
by: Kristoffer Persson | last post by:
Hi all! I'm trying to use a named EventWaitHandle to signal events between processes that run on the same computer. One of them is a service running as SYSTEM and the other one is a normal user. Creating the handle seems to be no problem, but when the other process is calling EventWaitHandle.OpenExisting with the same name, an UnauthorizedAccessException is thrown with the message "Access to the path is denied.". Any idea on how to...
3
9195
by: BLUE | last post by:
I've created a folder named TestDir in my wwwroot and I've created the associated virtual application from IIS management snap-in. I've given full control to TestDir to: IUSR, ASPNET, Network service, Anonimous access, Everyone, Users, VS Developers I've set write access and low application protection from IIS management snap-in.
0
8432
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.