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

MJGraf

Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Ahh, ok, that clarifies the Thumbnailer issues...

    I just did a clean pull from dev, compiled it as it is, deleted all the program\Team Mediaportal and Program Data\Team Mediaportal directories on all Computers, copied the clean build over and just exchanged (a) SQLCE with SQLite Plugin and (b) your NetworkNeighborhoodResourceProvider.
    Result: Same Problem as described above...

    But I have a suspicion:
    When I started the Client, it told me that it found an MP2-Server in the Network with the Name "htpc.fritz.box", to which I connected.
    The strange Thing is that there is no "Domain" or "Workgroup" called "Fritz.box". It's just that we have a FritzBox as Internet-Router. All the Computers are in the Workgroup "Workgroup" (Standard Setting of windows).
    So if the impersonation class tries to impersonate "htpc.fritz.box\USERNAME", it will probably fail, because the Computer itself doesn't know about the Workgroup "Fritz.box".
    I really don't know how the FritzBox manages to make the enumeration return xx.fritz.box, but this is just the Standard Setting of that FritzBox and since These Routers are fairly common, I think we should solve this Problem somehow. Maybe we can "Strip" just the computername (i.e. "htpc") from the string to do the impersonation as "htpc\USERNAME"?

    Michael
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Just saw that the ImpersonationHelper in the dev-branch is always called with sDomain=null and therefore sets
    sDomain = Environment.MachineName;
    This should definitedly work...
    @morpheus_xx Did you Change something there?
    The strange Thing is that with just my single Change in the constructor, I could browse the Network so something in your build must have changed.. Could you maybe upload or check in your sourcecode somewhere so that I can Play a bit with logging...
    Thanks!
    Michael
     

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,565
    3,946
    Lehmden
    Home Country
    Germany Germany
    Hi.
    I'm not using a Fritz.Box, I have a cheap Edimax 3G Router. For me the thumbnailer is working also. So this is a possibility.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I didn't change this part. One reason why it works on some shares and one some not could be different host operating systems: while it can work on a linux NAS (allowing anonymous) it might fail on regular Windows shares (with user/password).
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    The strange Thing is that there is no "Domain" or "Workgroup" called "Fritz.box". It's just that we have a FritzBox as Internet-Router. All the Computers are in the Workgroup "Workgroup" (Standard Setting of windows).
    I think this is the default "primary DNS suffix" that is used by Fritzboxes, so "PC" internally evaluates as PC.Fritz.Box for DNS lookups. So it's not a problem here.

    The strange Thing is that with just my single Change in the constructor, I could browse the Network so something in your build must have changed.. Could you maybe upload or check in your sourcecode somewhere so that I can Play a bit with logging...
    Changes are now commited at https://github.com/MediaPortal/MediaPortal-2/commits/FIX_4378_ServiceNetworkShares
    (had them in my fork before for wild testing ;))

    So for now the process starting is left...

    One thing you could test: please change the MP2-Server to "Network Service" instead of "System" and try an import with thumb-building.

    The way of "Impersonate->Process.Start" does not work, as new processes are always started under privileges of calling process (System) and not any impersonation (like interactive). There could be a way to run a process under impersonation by using http://www.pinvoke.net/default.aspx/advapi32/createprocessasuser.html. But then we would need to rewrite the ProcessUtils class and all input/output handling :(
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Not at home atm, so I could just have a look at the sources, but maybe I got it...
    When i enter USERNAME/PASSWORD as Network Settings I don't get an error, but I just can't see any Computers.
    The first Access to the Network when trying to add a share with this Provider should just list the Computers on the Network.
    In the constructor of the NetworkNeighborhoodResourceAccessor we check "if(IsServerPath(path)) return;". I guess this is first called after MP2-Server starts. This means that ImpersonateUser is not called and _impersonationContext is not set.
    The Computers are then listed with "GetChildDirectories", which then calls ImpersonateUser with an empty requested entity.
    Not sure if I got that correct, but somewhere there must be the error...
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    In the constructor of the NetworkNeighborhoodResourceAccessor we check "if(IsServerPath(path)) return;". I guess this is first called after MP2-Server starts.
    this is not a problem, IsServerPath only does simple string operations. ImpersonateUser() is so implemented that it can work with "null" as argument.

    Maybe I'm looking in the wrong place for the Access Denied exception...

    First I will add debugging logs to VideoThumbnailer to output full stacktrace, so we can see where the exception really comes from.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    This VideoThumbnailer does log the exception now completely as Error. Hope we will see more.
     

    Attachments

    • VideoThumbnailer.7z
      3.5 KB

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Small update:
    One thing you could test: please change the MP2-Server to "Network Service" instead of "System" and try an import with thumb-building.
    --> this does not work at all, as Network Service is not allowed to impersonate (just tested this).

    Next try: I created a new share on my HTPC, allowing only a real user to read. When I now try to import the share this works in general, but thumbnail creation fails the same way as for you @MJGraf.

    I contiuned the P/Invoke way and made some tests with "ProcessAsUser": this works! Client process are then started by the logged on user, thumbnails are created :D

    I still need to build a real solution and clean up the handling, but we have a way to go...
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Another update: I could fix the execution of external programs to run under the interactive user (many thanks @Oxan !!!)! So I think it's time for a new test run to see if everything works now.

    I've tested with remote NAS and also Windows shares, everything fine! Please also check if thumbnails are created and if mkv tags are read properly.

    Changes are now commited at https://github.com/MediaPortal/MediaPortal-2/commits/FIX_4378_ServiceNetworkShares
     
    Last edited:

    Users who are viewing this thread

    Top Bottom