473,804 Members | 3,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UnauthorizedAcc essException

I have app that writes text files to any location of the users choosing in
the network. It has been working for 18months. An exception has begun
occurring where a folder on a network share is denying access to the
File.CreateText (_filename) method. The user has write access. They can create
a text file through explorer no problem.

I am not a member of the group that has write access. As a test, I logged
into the network as a Domain Admin and ran the app. No problem writing the
text file.

The server is Win2003 sp1. The code is listed below. Any help would be
appreciated.
Thank you. tberry

.. . .
try {
FileIOPermissio n _fioPermit = new
FileIOPermissio n(FileIOPermiss ionAccess.Write , _filePath);
_fioPermit.Asse rt();

StreamWriter sw = File.CreateText (filename);// Exception occurs here.
for (i = 0; i < count; i++) {
sw.WriteLine((s tring)dataList[i]);
}// for
sw.Flush();
sw.Close();
sw = null;
return true;
} catch(Unauthori zedAccessExcept ion uae) {
// User does not have access rights to file, folder or drive.
.. . .

Nov 17 '05 #1
4 4211
trying using the unc path IE \\Server\drive_ c\
"ASP Yaboh" <AS******@discu ssions.microsof t.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I have app that writes text files to any location of the users choosing in
the network. It has been working for 18months. An exception has begun
occurring where a folder on a network share is denying access to the
File.CreateText (_filename) method. The user has write access. They can
create
a text file through explorer no problem.

I am not a member of the group that has write access. As a test, I logged
into the network as a Domain Admin and ran the app. No problem writing the
text file.

The server is Win2003 sp1. The code is listed below. Any help would be
appreciated.
Thank you. tberry

. . .
try {
FileIOPermissio n _fioPermit = new
FileIOPermissio n(FileIOPermiss ionAccess.Write , _filePath);
_fioPermit.Asse rt();

StreamWriter sw = File.CreateText (filename);// Exception occurs here.
for (i = 0; i < count; i++) {
sw.WriteLine((s tring)dataList[i]);
}// for
sw.Flush();
sw.Close();
sw = null;
return true;
} catch(Unauthori zedAccessExcept ion uae) {
// User does not have access rights to file, folder or drive.
. . .

Nov 17 '05 #2
Mel, I just finished trying that - same problem. Thank you though. T

"Mel Weaver" wrote:
trying using the unc path IE \\Server\drive_ c\
"ASP Yaboh" <AS******@discu ssions.microsof t.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I have app that writes text files to any location of the users choosing in
the network. It has been working for 18months. An exception has begun
occurring where a folder on a network share is denying access to the
File.CreateText (_filename) method. The user has write access. They can
create
a text file through explorer no problem.

I am not a member of the group that has write access. As a test, I logged
into the network as a Domain Admin and ran the app. No problem writing the
text file.

The server is Win2003 sp1. The code is listed below. Any help would be
appreciated.
Thank you. tberry

. . .
try {
FileIOPermissio n _fioPermit = new
FileIOPermissio n(FileIOPermiss ionAccess.Write , _filePath);
_fioPermit.Asse rt();

StreamWriter sw = File.CreateText (filename);// Exception occurs here.
for (i = 0; i < count; i++) {
sw.WriteLine((s tring)dataList[i]);
}// for
sw.Flush();
sw.Close();
sw = null;
return true;
} catch(Unauthori zedAccessExcept ion uae) {
// User does not have access rights to file, folder or drive.
. . .


Nov 17 '05 #3

"ASP Yaboh" <AS******@discu ssions.microsof t.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I have app that writes text files to any location of the users choosing in
the network. It has been working for 18months. An exception has begun
occurring where a folder on a network share is denying access to the
File.CreateText (_filename) method. The user has write access. They can
create
a text file through explorer no problem.

I am not a member of the group that has write access. As a test, I logged
into the network as a Domain Admin and ran the app. No problem writing the
text file.

The server is Win2003 sp1. The code is listed below. Any help would be
appreciated.
Thank you. tberry

. . .
try {
FileIOPermissio n _fioPermit = new
FileIOPermissio n(FileIOPermiss ionAccess.Write , _filePath);
_fioPermit.Asse rt();

StreamWriter sw = File.CreateText (filename);// Exception occurs here.
for (i = 0; i < count; i++) {
sw.WriteLine((s tring)dataList[i]);
}// for
sw.Flush();
sw.Close();
sw = null;
return true;
} catch(Unauthori zedAccessExcept ion uae) {
// User does not have access rights to file, folder or drive.
. . .


"UnauthorizedAc cessException" is thrown when the "user" running the code has
no "access permissions", note that FileIOPermissio n have nothing to do with
this, FileIOPermissio n is a Code Access permission.
All you can do is turn on auditing on the File server and check the identity
of the "user account" accessing the Fileshare when it fails.
Also make sure to use UNC paths as filename, using Drive mapping is in
general the cause of such failures,especi ally when the client is a long
running process (service).

Willy.


Nov 17 '05 #4
Willy,

I tried using the UNC in the path without success. I will try your
suggestion about turning auditing.

Thank you for your time,
Tom

"Willy Denoyette [MVP]" wrote:

"ASP Yaboh" <AS******@discu ssions.microsof t.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I have app that writes text files to any location of the users choosing in
the network. It has been working for 18months. An exception has begun
occurring where a folder on a network share is denying access to the
File.CreateText (_filename) method. The user has write access. They can
create
a text file through explorer no problem.

I am not a member of the group that has write access. As a test, I logged
into the network as a Domain Admin and ran the app. No problem writing the
text file.

The server is Win2003 sp1. The code is listed below. Any help would be
appreciated.
Thank you. tberry

. . .
try {
FileIOPermissio n _fioPermit = new
FileIOPermissio n(FileIOPermiss ionAccess.Write , _filePath);
_fioPermit.Asse rt();

StreamWriter sw = File.CreateText (filename);// Exception occurs here.
for (i = 0; i < count; i++) {
sw.WriteLine((s tring)dataList[i]);
}// for
sw.Flush();
sw.Close();
sw = null;
return true;
} catch(Unauthori zedAccessExcept ion uae) {
// User does not have access rights to file, folder or drive.
. . .


"UnauthorizedAc cessException" is thrown when the "user" running the code has
no "access permissions", note that FileIOPermissio n have nothing to do with
this, FileIOPermissio n is a Code Access permission.
All you can do is turn on auditing on the File server and check the identity
of the "user account" accessing the Fileshare when it fails.
Also make sure to use UNC paths as filename, using Drive mapping is in
general the cause of such failures,especi ally when the client is a long
running process (service).

Willy.


Nov 17 '05 #5

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

Similar topics

7
3142
by: Doug Taylor | last post by:
Hi, I originally posted this in dotnet.security, but have moved it here by request: Hi, I am trying to programmatically add a user with read permissions to the DACL of a registry key. All appears to go well until I try to
1
1849
by: Hal 9000 | last post by:
In c# we have a function that creates a virtual directory in IIS 6.0 using DirectoryServices API. The code looks like this: // log in to IIS DirectoryEntry rootDir = new DirectoryEntry("IIS://localhost/W3SVC/1/Root",ADMIN_USR,ADMIN_PSWD,AuthenticationTypes.Secure); // create a child virtual directory DirectoryEntry virtualDir = rootDir.Children.Add(name, rootDir.SchemaClassName); // set the virtual directory's physical path
12
8023
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
0
2334
by: nime | last post by:
I've got a problem. I cannot debug my app. which one contains WebBrowser control. I found a resolution but it's for an ASP related problem. I couldn't find a correct "user" to give permisson then I've added Everyone and refreshed policies (gpupdate /force), restarted VB IDE but still got the problem. What is the "worker process" for VB IDE? CODE:
8
6318
by: imukai | last post by:
I have a forms-based authentication application on our intranet - ASP.NET 3.5 (C#). For security purposes there is one specific .aspx file that we have enabled Integrated Windows Authentication turned on. Administrators in another group control access to this .aspx file via the file system. They have specifically set DENY access on this file to a few groups of employees. If one of those employees somehow manages to bring up that .aspx,...
0
10561
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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
10302
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
9132
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
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
6845
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();...
1
4277
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
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.