[fixed] [4378] Issues accessing network share using the service (1 Viewer)

MJGraf

Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Had the time now to do some more tests.
    My test Setup is as described above with just one Change (To make it more comparable to your Setup, Claus): Credentials on my HTPC are now the same as on all the other Computers, i.e. "User"/"PW1" also on htpc.

    Settings were:
    use credentials of interactive session on Server: unchecked
    use username and Password to Access Network: checked
    Username: User
    Password: PW1

    What I did:
    Start MP2-Server as application
    Add a global share on my htpc via NetworkNeighborhoodResourceProvider
    Stop MP2-Server application
    Start MP2-Server as Service
    Go to Shares configuration

    Result:
    Exactly the same error as described by Claus above. Now I can confirm 100%

    MP2-Server log says:
    MediaPortal.Utilities.Exceptions.IllegalCallException: Unable to access resource '//HTPC/Daten/Media/Music/test/'
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceAccessor..ctor(NetworkNeighborhoodResourceProvider parent, String path)
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceProvider.TryCreateResourceAccessor(String path, IResourceAccessor& result)
    bei MediaPortal.Common.ResourceAccess.ResourcePath.TryCreateLocalResourceAccessor(IResourceAccessor& result) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\MediaPortal.Common\ResourceAccess\ResourcePath.cs:Zeile 431.
    bei MediaPortal.Common.Services.ResourceAccess.UPnPResourceInformationServiceImpl.OnGetResourcePathDisplayName(DvAction action, IList`1 inParams, IList`1& outParams, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\MediaPortal.Common\Services\ResourceAccess\UPnPResourceInformationServiceImpl.cs:Zeile 305.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvAction.FireActionInvoked(IList`1 inParams, IList`1& outParams, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvAction.cs:Zeile 146.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvAction.InvokeAction(IList`1 inParameters, IList`1& outParameters, Boolean checkSignature, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvAction.cs:Zeile 129.
    bei UPnP.Infrastructure.Dv.SOAP.SOAPHandler.HandleRequest(DvService service, Stream messageStream, Encoding streamEncoding, Boolean subscriberSupportsUPnP11, CallContext context, String& result) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\SOAP\SOAPHandler.cs:Zeile 155.
    So it really seems to be the constructor. Will try to add "ImpersonateUser()" to the constructor and Report back...

    Michael
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Seems this is indeed the root cause.

    @Lehmden: Could you please try the attached DLL (just backup the old one and copy this one)?

    If it works I'll provide a patch. It seems it was just using(ImpersonateUser(){...} missing in the constructor of the NetworkNeighborhoodResourceProvider.

    Thanks,
    Michael
     

    Attachments

    • NetworkNeighborhoodResourceProvider.zip
      7.4 KB

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    No worries, take your time.

    @morpheus_xx: If Lehmden corfirms that it's working, I'd be glad if you could review the attached patch.

    Two remarks, however:
    1. This patch does not solve the problem I have when you need different credentials (a) on your MP2-Server for browsing the network and (b) for accessing the shares on another computer. A bigger rework would be required to achieve that (at least big enough to be too complicated for me...)
    2. I only added ImpersonateUser() to the constructor, because there the exception was thrown. I don't have enough knowledge to check, whether Impersonation should be called in other methods as well. I read a bit in the internet and found out that impersonation is always thread-based. So we currently assume that the thread, which calls the constructor of the NetworkNeighborhoodResouceAccessor is the same thread, which later calls e.g. OpenStream(). I just don't know if this assumption is correct. But even if we need Impersonation at other places as well, the patch should already improve the current situation.
    cheers,
    Michael
     

    Attachments

    • 0001-Added-Impersonation-to-the-constructor-of-NetworkNei.patch
      1.9 KB

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,562
    3,944
    Lehmden
    Home Country
    Germany Germany
    Hi.
    Did a first quick test. Seems to work as expected. Great. (y) As my NAS currently isn't running I can't do any deeper tests. Just added the Sample Pictures Folder from another PC as Share in MP2 and this seems to work. NAS will be up tonite again. Then I'll do some more tests.
     

    chefkoch

    Retired Team Member
  • Premium Supporter
  • October 5, 2004
    3,129
    1,634
    Dresden / Munich / Maastricht
    Home Country
    Germany Germany
    @Lehmden created a Mantis issue: http://mantis.team-mediaportal.com/view.php?id=4378
    Thanks (y)

    I assigned it to you @MJGraf hope that's fine ;)
    If you would like to you can create a branch based on dev, which includes your patch and link to it in Mantis while setting it to ready for testing or merging.
    Thanks for providing the patch (y)
     
    Last edited:

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    oh, oh, now I'm running into Trouble :D

    Sorry, @chefkoch, I don't think I even have git write Access - and trust me, you don't want me to have ;)

    Joking aside, I'm a complete git noob. I'm happy to learn, if you guide me step by step, but if you could take that part, it would probably be ten times as fast...

    Thanks,
    Michael
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Well, checking out the sources and compiling them is basically all I can do with git :D
    Afterward, I usually screw up my whole local git repository, followed by deleting it, checking out the sources and compiling again...
    Thanks for your help, Chefkoch!
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I only added ImpersonateUser() to the constructor, because there the exception was thrown. I don't have enough knowledge to check, whether Impersonation should be called in other methods as well. I read a bit in the internet and found out that impersonation is always thread-based. So we currently assume that the thread, which calls the constructor of the NetworkNeighborhoodResouceAccessor is the same thread, which later calls e.g. OpenStream(). I just don't know if this assumption is correct. But even if we need Impersonation at other places as well, the patch should already improve the current situation.
    Great find! I don't know if we need Impersonate() also in the other places, probably it could be required as well.
    Did a first quick test. Seems to work as expected. Great. (y) As my NAS currently isn't running I can't do any deeper tests. Just added the Sample Pictures Folder from another PC as Share in MP2 and this seems to work. NAS will be up tonite again. Then I'll do some more tests.

    I would like to get more test results, i.e. if playback works correctly and also if NAS can be accessed correctly.


    This patch does not solve the problem I have when you need different credentials (a) on your MP2-Server for browsing the network and (b) for accessing the shares on another computer. A bigger rework would be required to achieve that (at least big enough to be too complicated for me...)
    Yes, I know the current implementation has some room for improvement. But I also wanted to keep the need for to much configuration away from MP2. What we have now is the same, as if the MP2-Server runs as the interactive user (non-service).

    But we should note in wiki what is required to access shares: each system needs the same user/password as configured in server settings. If you run a domain at home, you could use a domain user as well (but who does this? ;))
     

    Users who are viewing this thread

    Top Bottom