locked
System.UnauthorizedAccessException in WebService using session RRS feed

  • Question

  • User1408399351 posted

    We are having an issue in which we have website using windows authentication.

    Then, we are passing the windows credentials to call web service using

    myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials
    myWebService.UseDefaultCredentials = True

    Within webservice we are getting the username of logged in user using  User.Identity.Name.ToString() (this is just performed to check if username is passed to service, not part of functionality)

    However, within the web service, a function that uses session is throwing 

     System.UnauthorizedAccessException

    This is the web service method:-

    <WebMethod(enableSession:=True)> _
    Public Function LogIn() As String

    ...

     oWMSession = New WINDREAMLib.WMSession  <--- error on this line

    ..

    End Function

    -This code works on website, but throws error on webservice, so we are wondering if this is an web service/sessions issue. Please guide.

    Friday, August 2, 2013 3:48 AM

Answers

  • User260886948 posted

    Hi,

    It seems that it is a permissions issue.

    As far as I know, if we host our project on Web Server. the default identity of ApplicationPool is ApplicationPoolIdentity(IIS7,NETWORK Author\Network services on IIS6). But there are both local account not Domain account. Thus I suggest you create a extra(particular) account and grant the approprivate rights to it(it can access the UNC share server). And impersonate the account in web.config.

     #ASP.NET Impersonation

    http://msdn.microsoft.com/en-us/library/xh507fc5(VS.71).aspx .

    #Understanding ASP.NET Impersonation Security

    http://www.west-wind.com/WebLog/posts/2153.aspx .

    Best Regards,
    Amy Peng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 4, 2013 9:30 PM