473,472 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ATL Server and access to local drive

Hello

I have VC++ .NET 2003 ATL Server project. In one of its method I need to write some information in a local txt file. This txt file and this ATL Server are on the same ‘C: \’ drive. When I tried it I just get ERROR_ACCESS_DENIED error from GetLastError function. What do I need to modify to let this ATL Server to write on local hard drive? Is it file’s access permission or ATL Server security settings

Thanks a lot for hel

Regard

Leoni

Nov 17 '05 #1
1 2339
Hello, Leonid

ATL Server applications run in the context specified in IIS configuration.
By default, the ATL Server application will impersonate the anonymous web
user (IUSR_MACHINENAME).
There are a few ways of working around this.

1) disable the anonymous access to the virtual directory where the ATL
Server application is installed. This way, IIS will require the credentials
of the remote user before launching teh request handling ( the ATL Server
code). Then, you can invoke AtlImpersonateClient from the ATL Server code to
impersonate the remote client. Now, if the remote client (the user that
launched the request) has permissions to write on your C drive, everything
will work smoothly

2) impersonate some local machine user which has permission to write in the
C drive in the ATL Server application for the code sequence that performs
the writing:
{
SetThreadToken(NULL, hToken); // start impersonation for current thread
// Write to disk

SetThreadToken(NULL, NULL) ;// end impersonation for current thread
}
hToken can be obtained by invoking LogonUser, details are available in MSDN
for both LogonUser and SetThreadToken
3) if your web application will be accessed by users that do not have
permissions on your C drive, you can leave the configuration intact and
create a folder on the C drive where the anonymous user (IUSR_<MACHINENAME>)
has permission to write. Use Explorer's security dialog to allow this user
to write in that folder
4) in the IIS configuration dialog for the virtual directory of the ATL
Server application, change the account used for anonymous access from
IUSR_<MACHINENAME> to some local user that has permissions to write in the
C: drive (or the folder on the C drive where you plan to write)

5) Change you application to write into a file in the virtual directory
itself and give Write permissions to that virtuall directory

6) Change the application's logic to use a database instead of file writing
Hope this helps,
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan


"Leonid" <an*******@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hello,

I have VC++ .NET 2003 ATL Server project. In one of its method I need to write some information in a local txt file. This txt file and this ATL
Server are on the same 'C: \' drive. When I tried it I just get
ERROR_ACCESS_DENIED error from GetLastError function. What do I need to
modify to let this ATL Server to write on local hard drive? Is it file's
access permission or ATL Server security settings?
Thanks a lot for help

Regards

Leonid

Nov 17 '05 #2

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

Similar topics

3
by: Helen | last post by:
How can I write a file to a mapped drive on a different server, from an ASP.Net application? Thanks Helen
1
by: Z0gS | last post by:
I got this problem for the web application I try to access files on a remote server. string dirs = Directory.GetDirectories(@"E:\vehicles") E drive is a map to a network drive. I get the...
3
by: Jon | last post by:
I'm calling Server.MapPath from global.asa through this line of code: Application("reports_dir") = Server.MapPath("Reports") The web application opens on a testing web server (not mine) at this...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
3
by: partybob99 | last post by:
Hi everyone. I have a very strange problem and I have no idea how to correct it. I created a VB.NET DLL that is used by several different apps for password file encryption/decryption. I have...
4
by: elmer.piano | last post by:
We have a directory of files on our ftp server. Is there a javacript to make a connection to the ftp server and compare files on a local drive and on the server? Files that have been changed or...
0
by: M Cavanagh | last post by:
I am fairly new using functions to return file info and I made an assumption that a function working on a local machine would work fine on a server. I have searched several Access books to find a...
21
by: lesperancer | last post by:
I've got an access97 reporting mdb that pulls data (77,000 rows) from a sql server table into a local table to run reports if the local table is part of the reporting MDB, the insert statement...
1
by: Bill Nguyen | last post by:
One of my apps (running in a terminal server session) needs to access a local USB drive /fash card. Is there a way to access local drives programmatically? Thanks Bill
0
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,...
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
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,...
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...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
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.