Problem Writing a File from a Web Service

Discussion in 'ASP .Net' started by =?Utf-8?B?QmlsbCBNYW5yaW5n?=, Feb 16, 2007.

  1. I have an internal ASP.NET 2.0 web service that does, among other things,
    expose a method that causes files to be written to a location that the user
    configures. The web service has been around for a while, under ASP.NET 1.0
    and it has just been updated to ASP.NET 2.0. The functionality in question
    has not changed.

    When testing the upgraded web service on Windows XP, I got an error when the
    file was created:

    Access to the path 'C:\MyFolder\myFile.ext' is denied.

    This looks like a security issue, so I checked the folder permissions for
    the ASPNET user (this is XP) and it had write permissions to the folder. I
    tried adding the ASPNET user to the local administrators group on the
    machine, to at least confirm that I have a permissions issue - the problem
    did not go away.

    Finally, I solved the problem by having the web service impersonate my
    Windows Domain account. I added a line like the following to the web.config
    file:

    <identity impersonate="true" userName="domain\myName" password="myPassword" />

    This solved the problem, but I don't understand why I had to do this and I
    don't want this to be the final solution.

    Does anyone understand what is going on?

    --
    Thanks,

    Bill Manring
    Wavefront Software, Inc.
     
    =?Utf-8?B?QmlsbCBNYW5yaW5n?=, Feb 16, 2007
    #1
    1. Advertising

  2. Well, if setting the impersonate element to your domain accout fixed the
    problem, then it stands to reason that whatever permission set you granted to
    the ASPNET user was insufficient. Either that, or the Webservice isn't
    actually running under the ASPNET user credentials.
    Peter

    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "Bill Manring" wrote:

    > I have an internal ASP.NET 2.0 web service that does, among other things,
    > expose a method that causes files to be written to a location that the user
    > configures. The web service has been around for a while, under ASP.NET 1.0
    > and it has just been updated to ASP.NET 2.0. The functionality in question
    > has not changed.
    >
    > When testing the upgraded web service on Windows XP, I got an error when the
    > file was created:
    >
    > Access to the path 'C:\MyFolder\myFile.ext' is denied.
    >
    > This looks like a security issue, so I checked the folder permissions for
    > the ASPNET user (this is XP) and it had write permissions to the folder. I
    > tried adding the ASPNET user to the local administrators group on the
    > machine, to at least confirm that I have a permissions issue - the problem
    > did not go away.
    >
    > Finally, I solved the problem by having the web service impersonate my
    > Windows Domain account. I added a line like the following to the web.config
    > file:
    >
    > <identity impersonate="true" userName="domain\myName" password="myPassword" />
    >
    > This solved the problem, but I don't understand why I had to do this and I
    > don't want this to be the final solution.
    >
    > Does anyone understand what is going on?
    >
    > --
    > Thanks,
    >
    > Bill Manring
    > Wavefront Software, Inc.
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 16, 2007
    #2
    1. Advertising

  3. Peter,

    Thanks for the reply. By placing the ASPNET account in the local
    Adminstrators group, it should have the same permissions as my Domain account.

    That leads me to believe that the web service isn't running under the ASPNET
    account, but I have done nothing to force it to be otherwise. How can I tell
    which account it is running under?

    --
    Thanks,

    Bill Manring
    Wavefront Software, Inc.


    "Peter Bromberg [C# MVP]" wrote:

    > Well, if setting the impersonate element to your domain accout fixed the
    > problem, then it stands to reason that whatever permission set you granted to
    > the ASPNET user was insufficient. Either that, or the Webservice isn't
    > actually running under the ASPNET user credentials.
    > Peter
    >
    > --
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short urls & more: http://ittyurl.net
    >
    >
    >
    >
    > "Bill Manring" wrote:
    >
    > > I have an internal ASP.NET 2.0 web service that does, among other things,
    > > expose a method that causes files to be written to a location that the user
    > > configures. The web service has been around for a while, under ASP.NET 1.0
    > > and it has just been updated to ASP.NET 2.0. The functionality in question
    > > has not changed.
    > >
    > > When testing the upgraded web service on Windows XP, I got an error when the
    > > file was created:
    > >
    > > Access to the path 'C:\MyFolder\myFile.ext' is denied.
    > >
    > > This looks like a security issue, so I checked the folder permissions for
    > > the ASPNET user (this is XP) and it had write permissions to the folder. I
    > > tried adding the ASPNET user to the local administrators group on the
    > > machine, to at least confirm that I have a permissions issue - the problem
    > > did not go away.
    > >
    > > Finally, I solved the problem by having the web service impersonate my
    > > Windows Domain account. I added a line like the following to the web.config
    > > file:
    > >
    > > <identity impersonate="true" userName="domain\myName" password="myPassword" />
    > >
    > > This solved the problem, but I don't understand why I had to do this and I
    > > don't want this to be the final solution.
    > >
    > > Does anyone understand what is going on?
    > >
    > > --
    > > Thanks,
    > >
    > > Bill Manring
    > > Wavefront Software, Inc.
     
    =?Utf-8?B?QmlsbCBNYW5yaW5n?=, Feb 16, 2007
    #3
  4. protected void Page_Load(object sender, System.EventArgs e)
    {
    Label1.Text = Page.User.Identity.Name +" : "+
    Page.User.Identity.AuthenticationType.ToString();

    }

    Cheers,
    Peter
    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "Bill Manring" wrote:

    > Peter,
    >
    > Thanks for the reply. By placing the ASPNET account in the local
    > Adminstrators group, it should have the same permissions as my Domain account.
    >
    > That leads me to believe that the web service isn't running under the ASPNET
    > account, but I have done nothing to force it to be otherwise. How can I tell
    > which account it is running under?
    >
    > --
    > Thanks,
    >
    > Bill Manring
    > Wavefront Software, Inc.
    >
    >
    > "Peter Bromberg [C# MVP]" wrote:
    >
    > > Well, if setting the impersonate element to your domain accout fixed the
    > > problem, then it stands to reason that whatever permission set you granted to
    > > the ASPNET user was insufficient. Either that, or the Webservice isn't
    > > actually running under the ASPNET user credentials.
    > > Peter
    > >
    > > --
    > > Site: http://www.eggheadcafe.com
    > > UnBlog: http://petesbloggerama.blogspot.com
    > > Short urls & more: http://ittyurl.net
    > >
    > >
    > >
    > >
    > > "Bill Manring" wrote:
    > >
    > > > I have an internal ASP.NET 2.0 web service that does, among other things,
    > > > expose a method that causes files to be written to a location that the user
    > > > configures. The web service has been around for a while, under ASP.NET 1.0
    > > > and it has just been updated to ASP.NET 2.0. The functionality in question
    > > > has not changed.
    > > >
    > > > When testing the upgraded web service on Windows XP, I got an error when the
    > > > file was created:
    > > >
    > > > Access to the path 'C:\MyFolder\myFile.ext' is denied.
    > > >
    > > > This looks like a security issue, so I checked the folder permissions for
    > > > the ASPNET user (this is XP) and it had write permissions to the folder. I
    > > > tried adding the ASPNET user to the local administrators group on the
    > > > machine, to at least confirm that I have a permissions issue - the problem
    > > > did not go away.
    > > >
    > > > Finally, I solved the problem by having the web service impersonate my
    > > > Windows Domain account. I added a line like the following to the web.config
    > > > file:
    > > >
    > > > <identity impersonate="true" userName="domain\myName" password="myPassword" />
    > > >
    > > > This solved the problem, but I don't understand why I had to do this and I
    > > > don't want this to be the final solution.
    > > >
    > > > Does anyone understand what is going on?
    > > >
    > > > --
    > > > Thanks,
    > > >
    > > > Bill Manring
    > > > Wavefront Software, Inc.
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 16, 2007
    #4
  5. User.Identity.Name came back as an empty string when I turned off
    impersonation. Does that mean it is running as the anonymous user?
    --
    Thanks,

    Bill Manring
    Wavefront Software, Inc.


    "Peter Bromberg [C# MVP]" wrote:

    > protected void Page_Load(object sender, System.EventArgs e)
    > {
    > Label1.Text = Page.User.Identity.Name +" : "+
    > Page.User.Identity.AuthenticationType.ToString();
    >
    > }
    >
    > Cheers,
    > Peter
    > --
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short urls & more: http://ittyurl.net
    >
    >
    >
    >
    > "Bill Manring" wrote:
    >
    > > Peter,
    > >
    > > Thanks for the reply. By placing the ASPNET account in the local
    > > Adminstrators group, it should have the same permissions as my Domain account.
    > >
    > > That leads me to believe that the web service isn't running under the ASPNET
    > > account, but I have done nothing to force it to be otherwise. How can I tell
    > > which account it is running under?
    > >
    > > --
    > > Thanks,
    > >
    > > Bill Manring
    > > Wavefront Software, Inc.
    > >
    > >
    > > "Peter Bromberg [C# MVP]" wrote:
    > >
    > > > Well, if setting the impersonate element to your domain accout fixed the
    > > > problem, then it stands to reason that whatever permission set you granted to
    > > > the ASPNET user was insufficient. Either that, or the Webservice isn't
    > > > actually running under the ASPNET user credentials.
    > > > Peter
    > > >
    > > > --
    > > > Site: http://www.eggheadcafe.com
    > > > UnBlog: http://petesbloggerama.blogspot.com
    > > > Short urls & more: http://ittyurl.net
    > > >
    > > >
    > > >
    > > >
    > > > "Bill Manring" wrote:
    > > >
    > > > > I have an internal ASP.NET 2.0 web service that does, among other things,
    > > > > expose a method that causes files to be written to a location that the user
    > > > > configures. The web service has been around for a while, under ASP.NET 1.0
    > > > > and it has just been updated to ASP.NET 2.0. The functionality in question
    > > > > has not changed.
    > > > >
    > > > > When testing the upgraded web service on Windows XP, I got an error when the
    > > > > file was created:
    > > > >
    > > > > Access to the path 'C:\MyFolder\myFile.ext' is denied.
    > > > >
    > > > > This looks like a security issue, so I checked the folder permissions for
    > > > > the ASPNET user (this is XP) and it had write permissions to the folder. I
    > > > > tried adding the ASPNET user to the local administrators group on the
    > > > > machine, to at least confirm that I have a permissions issue - the problem
    > > > > did not go away.
    > > > >
    > > > > Finally, I solved the problem by having the web service impersonate my
    > > > > Windows Domain account. I added a line like the following to the web.config
    > > > > file:
    > > > >
    > > > > <identity impersonate="true" userName="domain\myName" password="myPassword" />
    > > > >
    > > > > This solved the problem, but I don't understand why I had to do this and I
    > > > > don't want this to be the final solution.
    > > > >
    > > > > Does anyone understand what is going on?
    > > > >
    > > > > --
    > > > > Thanks,
    > > > >
    > > > > Bill Manring
    > > > > Wavefront Software, Inc.
     
    =?Utf-8?B?QmlsbCBNYW5yaW5n?=, Feb 16, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,410
    HNguyen
    Dec 21, 2004
  2. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    907
    dgleeson422111
    Jan 26, 2010
  3. Scott Baierl
    Replies:
    1
    Views:
    283
    Scott Baierl
    Jul 29, 2006
  4. Leo Violette
    Replies:
    0
    Views:
    1,056
    Leo Violette
    Apr 17, 2009
  5. Redhot
    Replies:
    0
    Views:
    771
    Redhot
    Jul 18, 2009
Loading...

Share This Page