locked
ASP.Net Impersonation and SAPI.DLL RRS feed

  • Question

  • I’m having problems using ASP.Net Impersonation while doing some com-interop with the Microsoft Speech API (sapi.dll).  For whatever reason when I impersonate a trusted account on my dev machine I get an “Access Denied” error when calling the Speak function.  I should note I’ve tried just about everything I can find out on the web to no avail.  I’ve tried setting AspCompat to “true” on the page directive, the impersonation account I am using is an Administrator on my box and has full read/write access to the filesystem.

    This code *will* work if I impersonate myself and not the trusted account i.e. <identity impersonate=”true” />.  I know it’s some sort of obscure security issue but I’m not sure what else there is to try.  Will the sapi.dll only work for the logged in user?  This code also works fine in a winforms app.

    Pretty straight forward code:

          SpFileStream spFileStream = new SpFileStream();

     

          SpVoice speech = new SpVoice();

                   

          SpAudioFormatClass format = new SpAudioFormatClass();

          format.Type = SpeechAudioFormatType.SAFTGSM610_11kHzMono;

          spFileStream.Format = format;

          string path = Server.MapPath("speech");

     

    spFileStream.Open(path + "\\dude.wav", SpeechStreamFileMode.SSFMCreateForWrite, false);

          speech.AudioOutputStream = spFileStream;

     

          //NOTE: This is where I get hosed

          speech.Speak("dude", SpeechVoiceSpeakFlags.SVSFDefault);

     spFileStream.Close();

    Please, before you reply telling me that the account I am using does not have the necessary rights to write to the filesystem I suggest you duplicate this scenario on your box.

    thanks

     

    Wednesday, April 9, 2008 2:13 PM

Answers