473,756 Members | 8,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

security issue, access denied, impersonate

Hi, all:

My asp.net application calles MS speech 5.1 and generate a wav file on
server's path. Everything runs perfectly on my development machine. But
when I move the appl to production server, I always get ERROR: Access
is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED )).
First I thought its the permission problem, so I set permission of that
directory to everyone (not an secure idea, but for test only). I found
out that I can write a text file to that path or create a wav file with
size 0k. whenever the speech try to speak to the filestream, the error
occured. see the following code.

SpeechVoiceSpea kFlags SpFlags =
SpeechVoiceSpea kFlags.SVSFlags Async;
SpVoice Voice = new SpVoice();

SpeechStreamFil eMode SpFileMode =
SpeechStreamFil eMode.SSFMCreat eForWrite;

SpFileStream spFileStream = new SpFileStream();
spFileStream.Op en(strFile, SpFileMode, false); //HERE IS
FINE
Voice.AudioOutp utStream = spFileStream;
Voice.Speak(pTe xt, SpFlags); //CATCH ERROR HERE
Voice.WaitUntil Done(-1);

spFileStream.Cl ose();

I put the same code into a windows appl and run it on my production
server, it works fine, so I think it must be the asp.net does not have
the authority to call the speach com object. (am I right here?)

I read some post talking about impersonate or ASPNET user account, but
still quite confusing.

1. Where can I set which account my asp.net runs on?
on my own machine, it runs on MACHINENAME\ASP NET, but on my production
server it runs on NT AUTHORITY\NETWO RK SERVICE. by using
System.Security .Principal.Wind owsIdentity.Get Current().Name;
Also, I cannot add ASPNET permission of my path, it always give me
that aspnet is not a valid user (that why I added everyone.)
2. I tried using impersonate and it works. But it is not a good idea as
I expose the user name and pwd in my config file. Also, I have to
create a same user on my laptop and the production server. IS that
impersonate means?

<authenticati on mode="Windows" />
<identity impersonate="tr ue" userName="admin istrator"
password="mypwd "/>

Can I do this impersonate in my code (aka, when I need to create the
wav file and write to the path) and how ?
Sorry for the long post and lots questions, this kind stuff always
confused me.

Thanks in advance
-rockdale

Nov 27 '06 #1
2 5277
Hi Rockdale,

You can use the WindowsIdentity .Impersonate method. The docs have an
example of code you can use:

http://msdn2.microsoft.com/en-us/library/w070t6ka.aspx

Joe
--
http://www.csharp-station.com
"rockdale" wrote:
Hi, all:

My asp.net application calles MS speech 5.1 and generate a wav file on
server's path. Everything runs perfectly on my development machine. But
when I move the appl to production server, I always get ERROR: Access
is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED )).
First I thought its the permission problem, so I set permission of that
directory to everyone (not an secure idea, but for test only). I found
out that I can write a text file to that path or create a wav file with
size 0k. whenever the speech try to speak to the filestream, the error
occured. see the following code.

SpeechVoiceSpea kFlags SpFlags =
SpeechVoiceSpea kFlags.SVSFlags Async;
SpVoice Voice = new SpVoice();

SpeechStreamFil eMode SpFileMode =
SpeechStreamFil eMode.SSFMCreat eForWrite;

SpFileStream spFileStream = new SpFileStream();
spFileStream.Op en(strFile, SpFileMode, false); //HERE IS
FINE
Voice.AudioOutp utStream = spFileStream;
Voice.Speak(pTe xt, SpFlags); //CATCH ERROR HERE
Voice.WaitUntil Done(-1);

spFileStream.Cl ose();

I put the same code into a windows appl and run it on my production
server, it works fine, so I think it must be the asp.net does not have
the authority to call the speach com object. (am I right here?)

I read some post talking about impersonate or ASPNET user account, but
still quite confusing.

1. Where can I set which account my asp.net runs on?
on my own machine, it runs on MACHINENAME\ASP NET, but on my production
server it runs on NT AUTHORITY\NETWO RK SERVICE. by using
System.Security .Principal.Wind owsIdentity.Get Current().Name;
Also, I cannot add ASPNET permission of my path, it always give me
that aspnet is not a valid user (that why I added everyone.)
2. I tried using impersonate and it works. But it is not a good idea as
I expose the user name and pwd in my config file. Also, I have to
create a same user on my laptop and the production server. IS that
impersonate means?

<authenticati on mode="Windows" />
<identity impersonate="tr ue" userName="admin istrator"
password="mypwd "/>

Can I do this impersonate in my code (aka, when I need to create the
wav file and write to the path) and how ?
Sorry for the long post and lots questions, this kind stuff always
confused me.

Thanks in advance
-rockdale

Nov 28 '06 #2
Thanks, will try it later.

What's the logonToken should I pass into the function

private static void ImpersonateIden tity(IntPtr logonToken)
?


Joe Mayo (C# MVP) wrote:
Hi Rockdale,

You can use the WindowsIdentity .Impersonate method. The docs have an
example of code you can use:

http://msdn2.microsoft.com/en-us/library/w070t6ka.aspx

Joe
--
http://www.csharp-station.com
"rockdale" wrote:
Hi, all:

My asp.net application calles MS speech 5.1 and generate a wav file on
server's path. Everything runs perfectly on my development machine. But
when I move the appl to production server, I always get ERROR: Access
is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED )).
First I thought its the permission problem, so I set permission of that
directory to everyone (not an secure idea, but for test only). I found
out that I can write a text file to that path or create a wav file with
size 0k. whenever the speech try to speak to the filestream, the error
occured. see the following code.

SpeechVoiceSpea kFlags SpFlags =
SpeechVoiceSpea kFlags.SVSFlags Async;
SpVoice Voice = new SpVoice();

SpeechStreamFil eMode SpFileMode =
SpeechStreamFil eMode.SSFMCreat eForWrite;

SpFileStream spFileStream = new SpFileStream();
spFileStream.Op en(strFile, SpFileMode, false); //HERE IS
FINE
Voice.AudioOutp utStream = spFileStream;
Voice.Speak(pTe xt, SpFlags); //CATCH ERROR HERE
Voice.WaitUntil Done(-1);

spFileStream.Cl ose();

I put the same code into a windows appl and run it on my production
server, it works fine, so I think it must be the asp.net does not have
the authority to call the speach com object. (am I right here?)

I read some post talking about impersonate or ASPNET user account, but
still quite confusing.

1. Where can I set which account my asp.net runs on?
on my own machine, it runs on MACHINENAME\ASP NET, but on my production
server it runs on NT AUTHORITY\NETWO RK SERVICE. by using
System.Security .Principal.Wind owsIdentity.Get Current().Name;
Also, I cannot add ASPNET permission of my path, it always give me
that aspnet is not a valid user (that why I added everyone.)
2. I tried using impersonate and it works. But it is not a good idea as
I expose the user name and pwd in my config file. Also, I have to
create a same user on my laptop and the production server. IS that
impersonate means?

<authenticati on mode="Windows" />
<identity impersonate="tr ue" userName="admin istrator"
password="mypwd "/>

Can I do this impersonate in my code (aka, when I need to create the
wav file and write to the path) and how ?
Sorry for the long post and lots questions, this kind stuff always
confused me.

Thanks in advance
-rockdale
Nov 28 '06 #3

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

Similar topics

8
11459
by: Paul | last post by:
Hello, I've been reading up on security in Java Applets and whilst I understand the concept, I can't successfully get my applet to read a file on my local machine. I discovered from http://java.sun.com/sfaq/#read: ----- Sun's appletviewer allows applets to read files that are named on the access control list for reading. The access control list for reading is null by default, in the JDK. You can allow applets to read directories or files...
0
3395
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has replied.can someone on this list please help? The issue should be trivial for experienced MySQL users, I'm just a novice, thanks!
3
5721
by: Ian | last post by:
The beginning of my assembly that I am getting the access error from looks like this. ********************************* Imports System.EnterpriseServices Imports System Imports System.Collections Imports System.Configuration Imports System.Data Imports System.Data.Common Imports System.Reflection
3
1607
by: James Woo via SQLMonster.com | last post by:
Hi All I am getting an access denied message when I launch the Virtual Server administration screen, however I can connect through the Virtual Machine remote connectivity without any problems. Please help, I upgraded my memory and need to change setting though Virtual Server Adminitration screen. Is there a way around this issue! Thank you in advance, James
3
3633
by: Roy Osherove | last post by:
Hi folks. I have an ASP.Net application that runs a .Net dll that uses WMI and ADSI(both managed) to connect to a given IIS root and search through it. When not using the ASP.Net client, but running from a winforms project - I can connect to both local and remote machines. However, when using the ASP.Net project - I get an "Access denied" exception. This happens when calling the ManagementScope.Connect() method.
12
5101
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\projects_cig\e4e3b3da\3c20ac69" is denied. The error goes on to say that the ASP.NET is not authorized...
0
3537
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the original question, the subject line is: ADODB.NET and "Access Denied" I have an ASP.NET page writtein in VB that uses ADODB. I just had to
2
3799
by: Shailesh Gajare | last post by:
Hi All, I have creating an ASP.Net application with two web servers. I am uploading a file which is being uploaded on one of the server, I want to copy the uploaded file on the other server at the same time. It says Access Denied. I am using File.Copy ( Source , Destination , true ) command in my code, where Source : the current physical location of the uploaded file
1
6651
by: Smoothj | last post by:
Hello all, when connecting to an IRC server with my java applet some of my members get this error code. java.security.AccessControlException : access denied (java.net.SocketPermission irc.xxx.xxx resolve) What can I do to solve this? Regards,
0
9456
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
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9846
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
8713
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
7248
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
5142
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3806
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
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.